Eline Sami

Eline Sami

  • NA
  • 47
  • 70.4k

using one variable to store two different paths of a folder

Aug 19 2014 3:51 AM
Hi


I have one specific folder which might be found on two different locations (depends on the operating system that is being used)

I need to set a code which checks those two locations and see if the folder exists in one of them and after that my code will use the path to get the files inside that folder.

Example:
 

string SourcePath; // It can be @"C:\Program files or @"C:\Documents or settings

so I need to use one single variable and store the paths in in order to use as following:

if (System.IO.Directory.Exists(SourcePath))
 {
    string[] files = System.IO.Directory.GetFiles(sourcePath);
}

Answers (7)