This is given by a colleague, but I only need the file names:
private List<string> getWavFileList()
{
string path = @"c\test automation\wave files";
string[] files = Directory.GetFiles(path, "*.wav");
List<string> list = new List<string>(files);
return list;
}
The output list contains the path and extension, and I only need the file name. I worked on my own method, but I can not compile it:
private List<string> getWavFileList()
{
StringBuilder builder = new StringBuilder();
string path = @"c\test automation\wave files";
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] smFiles = di.GetFiles("*.wav");
foreach (FileInfo fi in smFiles)
{
builder.Append(Path.GetFileNameWithoutExtension(fi.Name));
builder.Append(", ");
}
string files = builder.ToString();
List list = new List<string>(files);
return list;
source
share