我想使用 C# 客户端将文件从客户端机器安全地上传到网络服务器。获得一些示例应用程序将很有帮助。另外我想知道如何使用 ssl 证书实现这一点。
谢谢,
阿卜杜勒
WebClient webClient = new WebClient();
string webAddress = null;
try
{
webAddress = @"http://myCompany/ShareDoc/";
webClient.Credentials = CredentialCache.DefaultCredentials;
WebRequest serverRequest = WebRequest.Create(webAddress);
WebResponse serverResponse;
serverResponse = serverRequest.GetResponse();
serverResponse.Close();
webClient.UploadFile(webAddress + logFileName, "PUT", logFileName);
webClient.Dispose();
webClient = null;
}
catch (Exception error)
{
MessageBox.Show(error.Message);
}