Hi,
I need your help with the following code error. Please tell me what is wrong and which code to use.
I'm trying to open a CSV file to get the data out of it.
If I use the following code, it works:
Code:
Const FileName = "/table.csv"
StrWer = File.OpenText(Server.MapPath(FileName))
Unfortunately I have to use the full path as the file could be different and in different sites. If I use the following code
Code:
Const FileName = "http://www.simstrumenti.com/table.csv"
StrWer = File.OpenText(FileName)
I get and error message as following:
URI formats are not supported.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: URI formats are not supported.
Source Error:
Line 54:
Line 55: Const FileName = "http://www.simstrumenti.com/table.csv"
Line 56: StrWer = File.OpenText(FileName)
Line 57:
Line 58:
Stack Trace:
[ArgumentException: URI formats are not supported.]
System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) +7493079
System.IO.Path.NormalizePath(String path, Boolean fullCheck) +36
System.IO.Path.GetFullPathInternal(String path) +21
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) +411
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +65
System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) +87
System.IO.StreamReader..ctor(String path) +30
System.IO.File.OpenText(String path) +35
ASP.csvdata_aspx.ReadCSV() in \\boswinfs02\home\users\web\b2942\ez.yeouda\csvdata.aspx:56
ASP.csvdata_aspx.Page_Load(Object sender, EventArgs e) in \\boswinfs02\home\users\web\b2942\ez.yeouda\csvdata.aspx:9
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627