简体   繁体   English

安全地上传/下载文件,winforms c#和asp.net

[英]Upload/download files securly, winforms c# and asp.net

From a winforms application, I need to upload & download files to an asp.net web server using http/https. 从Winforms应用程序中,我需要使用http / https将文件上传并下载到asp.net Web服务器。

  • only need to send/receive one file at a time 一次只需要发送/接收一个文件
  • cannot use ftp, must use http/https 无法使用ftp,必须使用http / https
  • need progress bar 需要进度条
  • upload & download must be username/password authenticated 上传和下载必须经过用户名/密码验证

Is there an easy way to do this? 是否有捷径可寻?

The WebClient class should be able to do everything you need to do. WebClient类应该能够执行您需要做的所有事情。 Use either UploadFileAsync Or UploadDataAsync for the upload (and their counterparts for the download), normal HTTP authentication for the username and password (see the Credentials property) and the UploadProgressChanged event for tracking progress for your progress bar. 使用UploadFileAsyncUploadDataAsync进行上传(及其对应版本进行下载),对用户名和密码使用常规HTTP身份验证(请参阅Credentials属性),并使用UploadProgressChanged事件跟踪进度条的进度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM