下面是我的教练和我的朋友Win 7的给它工作得很好。我已经试过我的工作笔记本电脑和我的个人桌面......不断挖掘出以下错误StreamReader的问题找到文件
我不明白......我尽量更改权限的目录给大家只是踢去......它适用于他的复制粘贴,但不是我的。
“找不到路径的一部分 'C:\用户\ Wookie \我的文档\'。”
using System;
using System.IO;
class Program
{
static void Main()
{
// This line of code gets the path to the My Documents Folder
string environment = System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal) + "\\";
Console.WriteLine("Enter a file name in My Documents: ");
string input = Console.ReadLine();
// concatenate the path to the file name
string path = environment + input;
// now we can use the full path to get the document
StreamReader myFile = new StreamReader(path);
int n = int.Parse(myFile.ReadLine());
Console.WriteLine("read {0}", n);
Console.ReadLine();
}//End Main()
}//End class Program
你说它可以在你的朋友Windows 7上正常工作,你试图在哪个操作系统上运行它。 – 2012-07-29 22:40:31
添加一个'Console.Writeline(路径)'并仔细检查它是否存在。 – 2012-07-29 22:42:32
运行Win 7以及 – Dan 2012-07-29 22:43:04