如何在 C# 中找到父目录? [英] How do I find the parent directory in C#?
本文介绍了如何在 C# 中找到父目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用此代码查找调试目录
I use this code for finding the debug directory
public string str_directory = Environment.CurrentDirectory.ToString();
C:\Users\Masoud\Documents\Visual Studio 2008\Projects\MyProj\MyProj\bin\Debug"
如何找到下图所示的父文件夹?
How can I find the parent folder as shown below?
C:\Users\Masoud\Documents\Visual Studio 2008\Projects\MyProj\MyProj"
推荐答案
您可以使用 System.IO.Directory.GetParent()
检索给定目录的父目录.
You can use System.IO.Directory.GetParent()
to retrieve the parent directory of a given directory.
这篇关于如何在 C# 中找到父目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文