I have create next path:
StringBuilder sb = new StringBuilder();
sb.Append(Environment.CurrentDirectory.ToString());
Its path: d:\????????????????\?#\My projects\MyToolBar(new)\TestToolBar\TestToolBar\bin\Debug\
And i need: d:\????????????????\?#\My projects\MyToolBar(new)\TestToolBar\TestToolBar\bin\
How returning to the same directory ago?
How returning to the same directory ago?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Zoran HorvatRank #792 · 2.9K reputationPosted Aug 2, 2011, 6:13 AM EDT
DirectoryInfo dir = new DirectoryInfo(Directory.GetCurrentDirectory());
Directory.SetCurrentDirectory(dir.Parent.FullName);
Or:
Directory.SetCurrentDirectory(Directory.GetCurrentDirectory() + "\\..");
In the first case, you have directory path in dir.Parent.FullName.
Zoran
Dorababu MekaRank #457 · 5.5K reputationPosted Aug 2, 2011, 6:06 AM EDT
Try this strFilePath = Directory.GetCurrentDirectory(); strFilePath = Directory.GetParent(strFilePath).ToString(); StringBuilder sb = new StringBuilder(); sb.append(strfilepath)Mike JonsonRank #7,584 · 238 reputationPosted Aug 2, 2011, 6:19 AM EDT