[英]Path to resource files in a VS2010 project
I'm using VS 2010 and .NET 4.0. 我正在使用VS 2010和.NET 4.0。
I've created a solution, with a single console C# project. 我创建了一个带有单个控制台 C#项目的解决方案。 I've added a few folders in the project via context menu on project > Add > New folder.
我通过项目>添加>新建文件夹的上下文菜单在项目中添加了一些文件夹。 Then I put some files in there.
然后我在其中放了一些文件。
I now wish to get the path (or file handle) to one of those resources. 我现在希望获取这些资源之一的路径(或文件句柄)。 Is there a nice way to getting its path?
有没有一种很好的方法来走自己的路?
NOTE 1: The project is on a source control, so I need a way that will work on different file paths. 注意1:该项目位于源代码管理中,因此我需要一种可在不同文件路径上工作的方法。
NOTE 2: If possible, I don't want to use Directory.GetCurrentDirectory()
nor System.Reflection.Assembly.GetExecutingAssembly().Location
. 注意2:如果可能,我不想使用
Directory.GetCurrentDirectory()
或System.Reflection.Assembly.GetExecutingAssembly().Location
。
EDIT: 编辑:
It seems, I'd like the direct answer to this Stackoverflow question. 看来,我想直接回答这个 Stackoverflow问题。 I want the project directory, without the "bin\\Debug"
我想要项目目录,而没有“ bin \\ Debug”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.