在c#中如何读取网络服务器上的文件

c#如何读取url文件

string url = "https://www.example.com/example.txt"

// 下面的ServicePointManager代码只有在https时才需要
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;
System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Ssl3;

System.Net.WebClient webclient = new System.Net.WebClient( );
string text = webclient.DownloadString( url );
webclient.Dispose( );
日期:2020-04-11 22:50:24 来源:oir作者:oir