How to navigate a few folders up?

前端 未结 11 2313
感动是毒
感动是毒 2020-11-29 20:52

One option would be to do System.IO.Directory.GetParent() a few times. Is there a more graceful way of travelling a few folders up from where the executing assembly resides?

11条回答
  •  囚心锁ツ
    2020-11-29 21:32

    If you know the folder you want to navigate to, find the index of it then substring.

                var ind = Directory.GetCurrentDirectory().ToString().IndexOf("Folderame");
    
                string productFolder = Directory.GetCurrentDirectory().ToString().Substring(0, ind);
    

提交回复
热议问题