Cobert file list to string array of file names

Posted on 2006-05-21
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
    LVL 62

    Expert Comment

    by:Fernando Soto
    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 62

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    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…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 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

    9 Experts available now in Live!

    Get 1:1 Help Now