这是创建流阅读器的代码。它使用流阅读器从文件中读取所有行。
try {
using (var reader = new StreamReader( new FileStream(@"" + defaultPath + file, FileMode.Open))) {
while (!reader.EndOfStream) {
fileContents.Add(reader.ReadLine());
}
}
} catch (Exception e) {
Console.WriteLine(e.StackTrace);
}
当我调用它时它会出错
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
这是确切的错误:
System.NotSupportedException: The given path's format is not supported. at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) at HackEr.LuaFileReader.ReadFile(String file) in C:\Users\brandon\documents\visual studio 2010\Projects\HackEr\HackEr\HackEr\LuaFileReader.cs:line 30
我需要将参数添加到新文件流吗?我正在使用 C#,因此可以使用参数(字符串、文件模式)创建文件流。