[英]Reference txt file in solution folder across multiple projects for homework assignment
Basics of assignment分配的基础
I don't know how to reference across projects, and my developer lingo is still too underdeveloped for me to conduct a worthwhile Google search.我不知道如何跨项目引用,而且我的开发人员行话仍然太不发达,我无法进行有价值的 Google 搜索。 I simply don't know how to reference a relative path that keeps things contained.
我只是不知道如何引用保持事物包含的相对路径。 I only know how to reference an absolute path:
我只知道如何引用绝对路径:
StreamWriter outputfile;
outputfile = File.AppendText(@"C:\Users\...some-file-path...\Homework2\responses.txt)
Or deeper if it's in the bin\\debug folder.或者更深,如果它在 bin\\debug 文件夹中。 Speaking of, I don't care if it's in the debug folder of one project or another, or in the main solution folder.
说起来,我不在乎它是在一个项目或另一个项目的调试文件夹中,还是在主解决方案文件夹中。
I just want it to work since it's homework (although an explanation of common industry best practices would not be unappreciated, even though I'm going into IT).我只是希望它能够工作,因为它是家庭作业(尽管对常见行业最佳实践的解释不会不受欢迎,即使我要进入 IT)。 How do I reference the solution folder as the start of the path to which I need to find a file?
如何将解决方案文件夹作为我需要查找文件的路径的开头? I would ask if that's possible, but I know the reality of programming is that anything is possible if you're just willing to put enough knuckle grease into the project.
我会问这是否可能,但我知道编程的现实是,只要您愿意在项目中投入足够的关节油脂,一切皆有可能。
You can use ..
to go up a directory relative to the current one.您可以使用
..
上一个相对于当前目录的目录。 So going from C:\\Windows\\Temp
using ..\\..\\ProgramData
would get you to C:\\ProgramData
.所以从
C:\\Windows\\Temp
使用..\\..\\ProgramData
会让你到C:\\ProgramData
。
The current dir is referenced with .\\
for going downwards in the tree.当前目录用
.\\
引用,用于在树中向下移动。 So using the previous example .\\Temp1
would get you to C:\\Windows\\Temp\\Temp1
所以使用前面的例子
.\\Temp1
会让你到C:\\Windows\\Temp\\Temp1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.