【发布时间】:2011-01-19 12:57:33
【问题描述】:
我正在从事一个项目,其中有许多文本和 xml 文件。我在运行时从我的程序中读取了这些内容。
我在 app.config 文件中保留了这些文件的路径,但所有路径都是绝对路径,例如 "C:\my_project\help_files\rejectList.txt" 。
如果我只保留“\help_files\rejectList.txt”路径,程序会抛出 filenotfound 异常。
Can anyone please tell me how to set relative paths in C# applications?
我想设置类似“$root\help_files\rejectList.txt”的内容,并且在运行时 $root 应该解析为实际路径。
Is there any way in .net to set paths like this?
另外,我还有一个问题。我的项目也需要一些 dll。人们通常将dll保存在哪里?在与exe文件相同的文件夹中,还是我们应该创建一个名为“lib”的文件夹并将dll放在那里?
感谢和问候, 谢卡尔
【问题讨论】:
标签: c# relative-path app-config