Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否可以替代嵌套目录.GetParent()来浏览项目中的文件夹?_C#_Path - Fatal编程技术网

C# 是否可以替代嵌套目录.GetParent()来浏览项目中的文件夹?

C# 是否可以替代嵌套目录.GetParent()来浏览项目中的文件夹?,c#,path,C#,Path,我目前有一个项目,其结构中有几个文件夹。我正在处理PlayerDataHandler类,需要访问位于/Assets/Data中的XML文件 目前,我发现从/Source/Meta/PlayerInformation.cs到/Assets/Data获取流的唯一方法是编写以下代码行: string xpathXmlPath = System.AppDomain.CurrentDomain.BaseDirectory; xpathXmlPath = Directory.GetParent(Dir

我目前有一个项目,其结构中有几个文件夹。我正在处理
PlayerDataHandler
类,需要访问位于
/Assets/Data
中的XML文件

目前,我发现从
/Source/Meta/PlayerInformation.cs
/Assets/Data
获取流的唯一方法是编写以下代码行:

 string xpathXmlPath = System.AppDomain.CurrentDomain.BaseDirectory;
 xpathXmlPath = Directory.GetParent(Directory.GetParent(Directory.GetParent(xpathXmlPath).FullName).FullName).FullName + @"\Assets\Data\XPathElements.xml";
我相信有一个更干净的方法来实现这一点。有什么建议吗

另外,我还尝试了以下方法,结果是相同的(
\Overwatcher\overwatcherpf\overwatcherpf\bin\Debug\
):

Assembly.GetExecutingAssembly().Location
Assembly.GetEntryAssembly().Location
AppDomain.CurrentDomain.BaseDirectory