Reputation: 605
i am new to C# how can i set file path to project files i have tried these but it gives default windows file path how to do that?
sfdlg.InitialDirectory = Application.StartupPath + @"..\..\";
Application.StartupPath---> is my excutable file path. from this path to come back two `root folders` i use `@"..\..\"`
is there any way to get back to Two root folders?
Upvotes: 0
Views: 101
Reputation: 498914
You have inverted the path specifications - the ..
should be at the start of the path (assuming no drive name is there).
A safe way to use paths is to use them with the Path
class:
Path.Combine(Path.Combine(Application.StartupPath, ".."), "..");
The above should do the trick.
Upvotes: 1