Illegal Characters in Path Error When Downloading CSV File

霸气de小男生 提交于 2019-12-12 00:40:14

问题


I need download a CSV file and then read it. Here is my code:

tickerValue = "goog"
Dim strURL As String = "http://ichart.yahoo.com/table.csv?s=" & tickerValue
Dim strBuffer As String = RequestWebData(strURL)
Using streamReader = New StreamReader(strBuffer)
Using reader = New CsvReader(streamReader)

I keep getting this error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Illegal characters in path.

What am I doing wrong?

Additional Info

In another part of my program I use this code and it works fine.

Address = http://www.nasdaq.com/screening/companies-by-industry.aspx?exchange=AMEX&render=download
Dim strBuffer As String = Historical_Stock_Prices.RequestWebData(Address)
Using streamReader = New StringReader(strBuffer)
Using reader = New CsvReader(streamReader)

Isn't my second code the same concept as my problem code?


回答1:


you are giving it, essentially, a web url. somewhere in your code, it does not support the web url. it could be the streamreader. it could be the CsvReader. what line of code does this point to?

the best bet is to save the file TO DISK, then read from disk.

UPDATE

here is an example to SAVE to disk:

using writer as new StreamWriter("C:\Test.csv")
   writer.Write(strBuffer)
   writer.Close()
end using

here is an example to READ from disk:

using strReader as new StreamReader("C:\Test.csv")
   ' this code is presumably how it works for reading into the CsvReader:
   using reader as new CsvReader(strReader)
      ' now do your thing
   end using
   strReader.Close()
end using


来源:https://stackoverflow.com/questions/19932755/illegal-characters-in-path-error-when-downloading-csv-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!