Second path fragment must not be a drive or UNC name

Viewed 10974

How to read all image files in folder by environment path folder in main folder:

   string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "mainFolder"); 

for example if inner folder for one file path is:

  Bitmap bmp = new Bitmap(path + "/folder/pic1.bmp");

but I want read all files of mainFolder/folder:

pic1.bmp
pic2.bmp
pic3.bmp
pic5.bmp

Not sure how to do it properly:

foreach (string imageFileName in Directory.GetFiles(path, "/folder/*.bmp"))
{
    using (Bitmap bmp = new Bitmap(imageFileName))
    {
      // process 
    }
}

this way I have: Second path fragment must not be a drive or UNC name

and this way:

foreach (string imgFileName in Directory.GetFiles(path + "/folder/*.bmp"))

I got: Illegal characters in path.

3 Answers
Related