HOW CAN I READ ALL FILES IN A DIRECTORY TO AN ARRAY USING C#?

Lady Bird Johnson

Total Post:19

Points:133
Posted by  Lady Bird Johnson
C# 
C#
 1339  View(s)
Ratings:
Rate this:

I have a folder D:\MyDirectory that is full of tab-delimited text files, but the number of files is unknown at any given time. How Can  I read and store the names of the text files in the MyDirectory directory into an array?

  1. Hank Greenberg

    Post:12

    Points:84
    Re: How can I read all files in a directory to an array using C#?

    You should use System.IO.Directory.GetFiles() and if know the file extension then you should use use System.IO.Directory.GetFiles(@"C:\ MyDirectory*.txt")

      Modified On Mar-31-2018 06:02:17 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!