我遇到了一些webclient下載問題。 我想從一個網站收集一些數據,並在我的計算中使用數據(單獨的列)。簡單地複製和粘貼數據時(並手動刪除文件底部的空行),我不會出錯。但是,當試圖自動化它 - 我得到「路徑中的非法字符」錯誤。在文件結尾處認爲它是\ r和「」 - 這就是問題所在。我試圖使用.TrimEnd,但我仍然收到錯誤。有任何想法嗎? 。Webclient下載 - 路徑中的非法字符
輸出在當地人窗口(修改後的代碼「download.Split( '\ n');) 最後的值。 「\ r」 「\ r」 「」
static void userInterface()
{
string[] lines;
//Console.Write("Enter ticker: ");
//string contract = Console.ReadLine();
try
{
WebClient client = new WebClient();
string downloadString = client.DownloadString
("http://ds01.ddfplus.com/historical/queryeod.ashx?username=XX&password=XXX&symbol=clk12&maxrecords=30&data=daily");
downloadString = downloadString.TrimEnd('\r');
//lines = File.ReadAllLines(downloadString);
lines = downloadString.Split('\n');
int high = 1;
Program.TA(DateColumn(lines, high), OpenColumn(lines, high + 1), HighColumn(lines, high + 2),
LowColumn(lines, high + 3), CloseColumn(lines, high + 4));
}
你爲什麼要在你下載的字符串(而不是實際的文件名)上調用'File.ReadAllLines'? – 2015-03-02 15:59:58