[英]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.