string Email_Loc; //Stores the emails full path.
TextReader Msg_Reader = File.OpenText(Email_Loc);
Email_Msg = Msg_Reader.ReadLine();
Msg_Reader.Close();
but this
string Email_Loc; //Stores the emails full path.
TextReader Msg_Reader = File.OpenText(Email_Loc);
Email_Msg = Msg_Reader.ReadToEnd();
Msg_Reader.Close();
or this does not??
string Email_Loc = ""; //Stores the emails full path.
TextReader Msg_Reader = File.OpenText(Email_Loc);
while(Msg_Reader.ReadLine() != null)
{
Email_Msg += Msg_Reader.ReadLine();
}
Msg_Reader.Close();
I need to be able to read the entire file but when I try ether of the second two code blocks I get the following error.
System.NotSupportedException: The given path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[] str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path)
at SpamCenturion.MainClass.scanMessage(String Current_Msg, String Msg_Path)Where does Email_Loc get set? It does not appear to be set correctly in any of your examples.
Thanks for the replyDouglas.
I'm actually setting it higher up, but fortunately I figured out that it was just a simple oversight on my part.
A few lines further down I'm calling a method that actually wrote back to the file.
The only problem was that I was passing the file path to it twice.
And so the error "The given path's format is not supported".
I hadn't made it that far down in my debugging because it seemed that the code was failing at this point.
Sorry to waste your time.
Thanks again for the quick response.
0 comments:
Post a Comment