下载CSV文件时路径中的非法字符错误 [英] Illegal Characters in Path Error When Downloading CSV File

查看:763
本文介绍了下载CSV文件时路径中的非法字符错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要下载一个CSV文件,然后阅读它。这是我的代码:

  tickerValue =goog
Dim strURL As String =http:// ichart。 yahoo.com/table.csv?s=& tickerValue
Dim strBuffer As String = RequestWebData(strURL)
使用streamReader =新的StreamReader(strBuffer)
使用reader =新的CsvReader(streamReader)
/ pre>

我一直收到此错误: mscorlib.dll中发生类型为System.ArgumentException的未处理异常其他信息:非法字符路径。



我做错了什么?





在我的程序的另一部分,我使用这个代码,它工作正常。

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

我的第二个代码不是我的问题代码相同的概念吗

解决方案

你基本上是一个web网址。在你的代码中的某处,它不支持web url。它可以是streamreader。它可能是CsvReader。
这是指向哪一行代码?



最好的办法是保存文件TO DISK,然后从磁盘读取。



UPDATE



这里是一个保存到磁盘的示例:


$使用作为新的StreamWriter(C:\Test.csv)

  
writer.Write(strBuffer)
writer.Close
end使用

这里是从磁盘读取的示例:

 使用strReader作为新的StreamReader(C:\Test.csv)
这个代码可能是如何工作, CsvReader:
使用阅读器作为新的CsvReader(strReader)
'现在做你的事情
end使用
strReader.Close()
end使用


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?

解决方案

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

这篇关于下载CSV文件时路径中的非法字符错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆