Question

string ActualPath = "D:\Files\a             c"

DirectoryInfo di = DirectoryInfo(ActualPath);

The di.Exist is always false when a folder contains spaces between name... what is the problem in the code...where the directory is actualy exist.

Thanks in advance...

Was it helpful?

Solution

I don't think the problem is the spaces. I think that the problem is that you need to use the proper escape sequence for the backslashes in your path eg.

string ActualPath = "D:\\Files\\a             c";

OR

string ActualPath = @"D:\Files\a             c";

Try

string ActualPath = @"D:\Files\a             c";
DirectoryInfo di = new DirectoryInfo(ActualPath);   
if (di.Exists)
{
   //do something
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top