C#文件上传下载
使用WebClient的UploadFileAsync、UploadFile、DownloadFile、DownloadFileAsync方法,异步调用服务器上传下载数据。
带源码及解决方案
// 创建WebClient实例
WebClient myWebClient = new WebClient();
//访问权限设置
myWebClient.Credentials = redentialCache.DefaultCredentials;
//要上传的文件
FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
try{...}catch{...}
1