我正在以字符串形式获取执行程序集路径,但我不希望整个路径需要使用它的一部分,并且需要从该路径访问另一个文件夹。
假设我需要从文件夹中获取 xml
“E:\Mahi_WorkSpace\TFS\Atrias.WebAutomationTesting\XmlFolder”
我的执行程序集路径在哪里
" E:\Mahi_WorkSpace\TFS \Atrias.WebAutomationTesting\TestResults\t.mahidharreddy_123 2016-10-24 07_39_26\Out"
现在我只需要执行程序集字符串中的“E:\Mahi_WorkSpace\TFS\Atrias.WebAutomationTesting\”
public string GetStringBody()
{
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
string path=Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
//srting xmlpath=??
return xmlpath;
}
最佳答案
试试这个。
字符串路径 = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestRunDirectory));
这将为您提供由 Atrias.WebAutomationTesting
创建的 TestResults
文件夹的父目录,我相信这就是您正在寻找的内容。
关于c# - 修改生成的执行程序集路径c#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40211449/