在一个Visual Studio环境,项目A(ASP.NET)引用项目B(C#)在我的解决方案是这样的:
In an Visual Studio environment, Project A (ASP.NET) references Project B (C#) in my solution like this:
Solution
├─Project B
│ ├─data.txt
│ └─process.cs (a class BB with static initialization new FileStream("data.txt"))
└ Project A (referencces Project B)
├─bin
│ └─data.txt (copied from project B each time project B changes)
└─Controllers
└─mycontroller.cs (references the class BB)
现在的问题是,当我运行的应用程序,工作目录是 C:\ Program Files文件(x86)的\ IIS防爆preSS \
,使数据.TXT不能从 process.cs
的编译版本,这是在读斌
。
The problem is that when I run the application, the working directory is C:\Program Files (x86)\IIS Express\
, so that data.txt cannot be read from the compiled version of process.cs
which is in bin
.
目前,要解决这个问题,我手动复制的data.txt
到这个文件夹,但这种方法是不可行的。
需要注意的是改变B必须是相干取决于B之外的项目,这是不是所有的ASP.NET项目。
For the moment, to solve the problem, I manually copied data.txt
to this folder, but this solution is not viable.
Note that changes to B must be coherent with other projects depending on B, which are not all ASP.NET project.
什么改变了我应该做这样的data.txt
是从我的项目访问,无需依靠我复制的data.txt
文件到 IIS防爆preSS
目录?
What changes should I make so that data.txt
is accessible from my project without relying on me to copy the data.txt
file to the IIS Express
directory?
我想端口我的程序的Azure在线,我不能依靠这种方法。感谢您的帮助。
I would like to port my program to Azure Online and I cannot rely on this method. Thank you for your help.
其他链接答案:
这个答案是ASP.NET - 具体的,我不能添加使用Server.Mappath因为项目不知道这件事 这个答案参考项目的路径,但不给我有关如何修改它们的提示。 This answer is ASP.NET - specific, I cannot add server.MapPath because the project does not know about it. This answer references project paths, but does not give me an hint about how to modify them.注意改变B必须是相干取决于B之外的项目,这是不是所有的ASP.NET项目
"Note that changes to B must be coherent with other projects depending on B, which are not all ASP.NET project"
不知道什么相干,就意味着你的依赖项目B上的其他项目背景下... 但是,下列选项浮现在脑海中 -
Not sure what coherent would mean to you in context of other projects which depend on project B... But following options come to mind -
嵌入的data.txt作为项目B.项目B产生组装的资源,就可以读取该文件作为资源(这是假设,文件内容不需要构建后进行修改) 见ResourceManager类来处理嵌入组件的资源。 的http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager(v=vs.110).aspx
Embed data.txt as a resource in the assembly generated for project B. Project B, can then read the file as a resource (This assumes, file contents do not need to be modified after the build) See ResourceManager class for handling resources embedded in assemblies. http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager(v=vs.110).aspx
如果它适用于项目B,扫描子目录的文件的所有客户。这是更hackish的..但实际上取决于场景B项目。
If it works for all clients of Project B, scan sub-directories for the file.. This is more hackish.. but really depends on the scenarios for project B.
上一篇:是否可以安全使用ContinueWith作为"最后"操作?操作、安全、ContinueWith、QUOT
下一篇:你有什么需要传递给v4.widget.DrawerLayout.isDrawerOpen()/。openDrawer()/。closeDrawer()你有什么、widget、DrawerLayout、