Learn how to a build a cloud-first strategyRegister Now


Cobert file list to string array of file names

Posted on 2006-05-21
Medium Priority
Last Modified: 2010-04-16

I have a list of files in an array of FileInfo what i want is to change this into a list of fileNames in a string array

whats the best way to do this?
Question by:kplonk
  • 2
LVL 64

Expert Comment

by:Fernando Soto
ID: 16729629
Hi  kplonk;

This should do it for you.

        Dim di As New DirectoryInfo("C:\Temp")
        Dim fInfo() As FileInfo = di.GetFiles()
        Dim filenames(fInfo.Length - 1) As String

        For idx As Integer = 0 To fInfo.Length - 1
            filenames(idx) = fInfo(idx).Name        ' Just the file name
            'filenames(idx) = fInfo(idx).FullName    ' Path with file name

LVL 64

Accepted Solution

Fernando Soto earned 80 total points
ID: 16729699
Hi  kplonk;

Sorry the initial post was in the wrong langage. Here it is in C#.

        DirectoryInfo di = new DirectoryInfo(@"C:\Temp");
        FileInfo[] fInfo = di.GetFiles();
      string[] filenames = new string[fInfo.Length];

      for( int idx = 0; idx < fInfo.Length; idx++)
            filenames[idx] = fInfo[idx].Name;        // Just the file name
            //filenames[idx] = fInfo[idx].FullName;    // Path with file name


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month21 days, 1 hour left to enroll

810 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