我想使用C#客户端从客户端计算机安全地上传文件到网络服务器。获得一些示例应用将会很有帮助。另外,我想知道如何使用ssl证书实现此目的。
谢谢,
阿都
答案 0 :(得分:2)
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);
}