您好,我试图通过c#上传一个文件到我的web服务器上,当我上传文件时出现问题我的应用程序冻结,直到文件完成上传,我想要上传异步但我似乎无法让代码在这里工作,有代码和我不断收到的错误。将上传文件转换为uploadfileasync c#
此代码有效,但会冻结表单。
WebClient wc = new WebClient();
wc.Credentials = new System.Net.NetworkCredential(TxtUsername.Text, TxtPassword.Text);
string Filename = TxtFilename.Text;
string Server = TxtServer.Text + SafeFileName.Text;
wc.UploadFile(Server, Filename);
但是,如果我这样做的代码,我会得到一个错误。
WebClient wc = new WebClient();
wc.Credentials = new System.Net.NetworkCredential(TxtUsername.Text, TxtPassword.Text);
string Filename = TxtFilename.Text;
string Server = TxtServer.Text + SafeFileName.Text;
wc.UploadFileAsync(Server, Filename);
和当试图使它异步
Error 1 The best overloaded method match for System.Net.WebClient.UploadFileAsync(System.Uri, string)' has some invalid arguments.
Error 2 Argument 1: cannot convert from 'string' to 'System.Uri'
谢谢!非常!! – Terrii