2013-08-07 35 views
-1

我写了我简单的工具,它加载一些配置:子程序使用父应用程序路径

stream = new StreamReader("configuration.xml"); 

作为独立它的工作原理,但是当我开始像他们寻找configuration.xml文件在父应用程序路径procces。这是正常的行为吗?

C:\My simple Tool\tool.exe 
C:\My simple Tool\configuration.xml 

C:\ParentTool.exe 

而且为ParentTool.exe subproccess的tool.exe应用寻找C:\configuration.xml但不是在"C:\My simple Tool\",我想。

+0

您是否尝试过将在同一目录下的两个子应用程序和它的配置文件作为父应用程序? –

+0

是的,这是正常行为。当你传入一个相对路径(比如“configuration.xml”)时,它会在当前程序当前正在执行的相同目录中查找该文件。这不仅是标准.NET的标准,而且对于网站,DOS等等 – Tim

回答

0

你可以尝试改变:

stream = new StreamReader("configuration.xml"); 

要:

stream = new StreamReader(@"C:\My simple Tool\configuration.xml");