C#从当前目录加载一个XML文件?(C# Loading a xml file from the current directory?)
我在我的C#winform应用程序中使用下面的代码行,这很好,但偶尔如果程序正在从命令行运行,则会出现无法找到config.xml文件的错误。 这是因为“工作目录”不同(我认为),我需要说“从当前目录加载config.xml”,我该怎么做?
docXML.Load("config.xml");谢谢乔纳森
I use the line below in my C# winform app, this works great but occasionally if the program is being run from the command line I get an error that the config.xml file cannot be found. This is because the 'working directory' is different (I think), I need to say "load config.xml from current directory", how would I do this?
docXML.Load("config.xml");Thanks Jonathan
最满意答案
string fileName = Path.Combine(Application.StartupPath, "config.xml"); string fileName = Path.Combine(Application.StartupPath, "config.xml");更多推荐
发布评论