Uri formats are not supported
Uri formats are not supported
Uri formats are not supported
Uri formats are not supported
Uri formats are not supported
Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported
Uri formats are not supported Uri formats are not supported
Uri formats are not supported
Go Back  Xtreme Visual Basic Talk > > > Uri formats are not supported


Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2012, 12:41 PM
pippo1111 pippo1111 is offline
Freshman
 
Join Date: Oct 2005
Posts: 31
Question Uri formats are not supported


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
Reply With Quote
  #2  
Old 01-06-2012, 01:41 PM
PlausiblyDamp's Avatar
PlausiblyDampUri formats are not supported PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

The File class is for working with local files (i.e. local pc or on the local network) and not for working with resources on the internet. If you need to read from a file that you only have a full URL to then you are probably better of looking at something like the WebClient class as an alternative.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 01-06-2012, 02:45 PM
pippo1111 pippo1111 is offline
Freshman
 
Join Date: Oct 2005
Posts: 31
Default

Thank you very much it worked!
I post you the code I used also for future readers:

Code:
Const FileName = "http://www.domain.com/table.csv"
CSVdata = fileReader.OpenRead(FileName)
Dim sr As StreamReader
sr = New StreamReader(CSVdata)
strLine = sr.ReadLine()
Do Until strLine Is Nothing
'****************************************
'*****     Insert here code to read each line    *****
'****************************************
Loop
CSVdata.Close()
Reply With Quote
Reply

Tags
open csv file


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Uri formats are not supported
Uri formats are not supported
Uri formats are not supported Uri formats are not supported
Uri formats are not supported
Uri formats are not supported
Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported Uri formats are not supported
Uri formats are not supported
Uri formats are not supported
 
Uri formats are not supported
Uri formats are not supported
 
-->