[英]Relative path to a file in C#?
I've been working on an assignment for college which involves reading in some variables from a CSV file. 我一直在为大学分配作业,其中涉及从CSV文件读取一些变量。 I've completed my code and have everything working. 我已经完成了代码,一切正常。
When referring the the CSV file I use a line of code similar to the foloowing: 当引用CSV文件时,我使用类似于以下代码行:
File.ReadAllLines(@"C:\Users\FILE\LOCATION\ON\DISK\FILE.CSV")
The only problem is that when i submit my code to be graded, obviously when who ever is marking the code tries to compile and run it will be greeted with an unhandled exception. 唯一的问题是,当我提交要评分的代码时,很明显,当谁标记该代码试图编译并运行该代码时,将会遇到未处理的异常。
Can I place the CSV somewhere in the project folder and refer to it with a relative path (as can me done in HTML)? 我可以将CSV放在项目文件夹中的某个位置,并用相对路径引用它吗(就像在HTML中一样)?
I've tried using answers to similar questions on this site, but I'm pretty new to programming and don't understand some of the answers. 我已经尝试过在此站点上使用类似问题的答案,但是对于编程我还是很陌生,不了解其中的一些答案。
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.