For fejl når jeg prøver at indlæse en text fil med readline
Hejsajeg anvender dette eksempel fra MSDN
// Read the file and display it line by line.
System.IO.StreamReader file = new System.IO.StreamReader("c:\\test.txt");
while ((line = file.ReadLine()) != null)
{
Console.WriteLine(line);
counter++;
}
file.Close();
// Suspend the screen.
Console.ReadLine();
Jeg er sikker på filen eksistere
C:\Users\Administrator>dir c:\*.txt
Volume in drive C has no label.
Volume Serial Number is 58CE-B5D8
Directory of c:\
20-Mar-11 11:13 AM 151 test.
1 File(s) 151 byt
0 Dir(s) 47,076,843,520 byt
C:\Users\Administrator>
Jeg for denne fejl når jeg kører programmet jeg kan ikke gennemskue om det er en opsætning i visual studio eller læse rettigheder til filen der er forkert
Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'c:\test.txt'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURIT
Y_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Administrator\documents\visual studio 2010\Projects\justify_uge11\justify_uge11\Program.cs:line 25