Answer the question
In order to leave comments, you need to log in
How to get the names of all files in a folder?
I'm writing here until I've done something as ugly as possible). You need to get the names of all the files in the folder, so that later they can be parsed and searched for what you need.
I tried this and thought I was close to success:
var test = "..."; // тут путь к папке
string[] test1 = Directory.GetFiles(test);
var test = "C:/Users/Hristoforov/hgtwithourarch/Belarus";
DirectoryInfo di = new DirectoryInfo(test);
string[] test1 = new string[Directory.GetFiles(test).Length];
int i = 0;
foreach (var s in di.GetFiles())
{
test1[i] = s.Name;
i++;
}
Answer the question
In order to leave comments, you need to log in
1 - var fnOnly = Path.GetFileName(fullPath)
2 -
var files = Directory.GetFiles(@"c:\").Select(fn => Path.GetFileName(fn));
it will be IEnumerable var files = Directory.GetFiles(@"c:\").Select(fn => Path.GetFileName(fn)).ToArray();
Use GetFileName (String) :
https://docs.microsoft.com/en-us/dotnet/api/system...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question