JimiJ13
asked on
Verify Existence of Directory
Dear Experts,
I have a folder in Table column Path = "D:\DL\NewRpt\" that physically exists.
However, when I check using Directory.Exists("D:\DL\Ne wRpt\") always return negative.
Any help would be gladly appreciated.
I have a folder in Table column Path = "D:\DL\NewRpt\" that physically exists.
However, when I check using Directory.Exists("D:\DL\Ne
Any help would be gladly appreciated.
Because you're forgetting that backslash means something special inside of C# strings. You need to escape the slashes in order to treat them as a part of the path and not special characters. You can do that in two ways:
Double-Up
Use the @ Modifier
Double-Up
Directory.Exists("D:\\DL\\NewRpt\\")
Use the @ Modifier
Directory.Exists(@"D:\DL\NewRpt\")
ASKER
That's right but how it can be formatted using column value as variable?
I do not understand the question.
ASKER
The Directory can be dynamically at the table Settings with the value as shown attached. That value shall be retrieved every time, as is, but it will not be recognized by C# unless formatted as: "D:\\DL\\NewRpt\\" or @"D:\DL\NewRpt\".
I hope that makes sense.
Directory.png
I hope that makes sense.
Directory.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I wonder why I was not getting that same result earlier, now is working fine. Thanks anyway for leveling up my understanding.
ASKER
Thanks.
ASKER