Search code examples
c#filedirectorystreamreaderfilereader

Get informations about files in folder


Please can you help me how can i get informations about files in folder? Because i need exactly get trace from all files in folder.

For Examples:

Trace is:

G:/Program Files/test/vse - here is all image files what i need

I created list where i will save trace from this files. And i need automatically get trace from individual files in the folder.

Important is that all files have individual name "1 - 100.jpg" if all will be work correctly so this will be out informations:

I need this result:

List<string> trace = new List<string>() which contains all trace with his name about file.

For Example:

G:/Program Files/test/vse/1.jpg
G:/Program Files/test/vse/2.jpg
G:/Program Files/test/vse/3.jpg
...
...
G:/Program Files/test/vse/100.jpg

I really thx for all answers.


Solution

  • Try something like this:

    var listOfFiles = new  List<String>();
            string [] fileEntries = Directory.GetFiles(targetDirectory);
            foreach(string fileName in fileEntries)
                {
                    lisOfFiles.Add(fileName);
                }
    

    for more info look here : http://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx