I Cant Understand This Error Value of type '1-dimensional array of String' cannot be converted to 'String'.

Posted on 2004-11-23
Last Modified: 2008-02-01

I keep reciving this error

'Value of type '1-dimensional array of String' cannot be converted to 'String'.

On the follwing Code :
 Files = CStr(dirLocalp.GetFiles(CStr(MTdir)))

The Files and MTdir variables are both of string type

any comments ??
Question by:1DrPC1
    LVL 1

    Author Comment

    I tried to ensure that the tow varibls are of string type by using Cstr( ) Function
    LVL 5

    Expert Comment

    GetFiles returns an array
    CSTr expects a singular item, and returns a string

    Before performing the CStr, you need to loop through all of the items that getfiles returns, and Cstr each one individually
    LVL 19

    Accepted Solution

    Hope you understand the error
    you are trying to store an Array of Strings in a String
    use the following instead

    Files = String.Join(" " ,dirLocalp.GetFiles(MTdir))

    This will join all the array elements and form one single String and store in the variable Files

    LVL 1

    Author Comment


    I think this is help :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    I'm currently working for a company where I have to upgrade over 50 VB6 programs to VB.NET 2008.  So far I'm about half way through, and I've learned quite a few tricks that drastically improve the performance of VB.NET apps. Because there are a…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now