-3
的路径,文本文件(d:>重考测验>测验),我得到的,说:“给定路径的格式不支持”的StreamReader,路径格式不支持
var pathToFile = @"..\..\..\D:\Files\quiz.txt";
using (StreamReader sr = new StreamReader(pathToFile, true))
{
for (int x = 0; x < 50; x++)
{
QuestNo[x] = questions[pos].QuestionNum = sr.ReadLine();
for (int y = 0; y < 1; y++)
{
QuestLevel[x] = questions[pos].Level = sr.ReadLine();
}
for (int y = 0; y < 1; y++)
{
Quest[x] = questions[pos].Question = sr.ReadLine();
}
for (int y = 0; y < 1; y++)
{
QuestAns[x] = questions[pos].answer = sr.ReadLine();
}
}
尝试VAR pathToFile = @ “d:\文件\ quiz.txt”; – Yagzii 2014-09-25 08:39:32
试过,但它说无法找到路径'D:\ Files \ quiz.txt'的一部分。 – user3666446 2014-09-25 08:41:44
检查文件是否确实存在。检查文件夹路径。检查大写字母和小写字母是否匹配 – Yagzii 2014-09-25 08:45:54