[英]URI formats are not supported when reading all lines
我收到以下錯誤:
URI formats are not supported.
string path = @"http://...../xml/en/df.js";
String[] allLines = System.IO.File.ReadAllLines(path);
編輯:
問題: System.IO.File
不支持從Internet下載文件。
System.IO.File
僅支持本地驅動器的路徑
解決方案:您應該使用WebClient.DownloadFile
從Internet URL
下載文件。
解決問題的步驟:
1.使用WebClient.DownloadFile
將文件下載到本地路徑。
2.將下載路徑分配給IO.File()以從文件讀取行。
步驟1:下載文件。
String source="http://mypath/path2/myfile.js";
String destination=@"c:\myfile.js";
void DownloadMyFile()
{
using (WebClient webClient = new WebClient())
{
webClient.DownloadFile(source,destination);
}
}
步驟2:從IO.File
庫訪問文件
String[] allLines =System.IO.File.ReadAllLines(destination);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.