I have a program where I can make folders and put files into them but I want to know which folders already exist.
As example :
In my application folder bin/debug, I have 2 folders, folder 1 and folder 2.
So when I run my program I want the name of those 2 folders to be listed into a listview so I can see which folder already exist.
Anybody knows how I can do that?
if you know about the binding, the rest is simple: By this you get all dictionaries in your execution (bin/debug) directory
DirectoryInfo directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); DirectoryInfo subdirectory = directory.GetDirectories(); List<string> directoryNames = subdirectory.Select(subdir => subdir.Name).ToList();
This way you'll get all folder in your execution directory that exist, no matter of the name. You can however check if the name is folder1 or folder two, on you subdictonaries if you'd like to