通过C#.net2.0将文件上传到Web服务器吗? [英] Upload a file at Web server through C#.net2.0?
问题描述
你好朋友,
我正在尝试通过本地语言将文件上传到Web服务器,但是无法将其保存在Web服务器上.我已经提供了相同所需的所有必要凭据,但仍然不能再一次出现错误,原因是:远程服务器返回错误:(404)未找到..
我无法弄清哪里出了问题,因为从我读过的许多文章中,只需要两到三行代码即可执行相同的操作.
请在下面找到代码:
Hello friends,
I am trying to upload file through my locals to a Web Server but I am not able to save it on the Web Server. I have given all the necessary credentials required for the same but still time an again i get an error as: The remote server returned an error: (404) Not Found..
I am not able to sort out where I am going wrong as from many of the articles I have read that it requires just two to three lines of code to perform the same.
Please find the code below:
try
{
WebClient client = new WebClient();
string myFile = fileInfo.FullName;
string newAttachPath = fileStoragePath + myFile;
//client.Credentials = CredentialCache.DefaultCredentials;
NetworkCredential netwrkCreden = new networkCredential("username","password","domain");
client.Credentials = netwrkCreden;
client.UploadFile(newAttachPath, "PUT",myFile);
client.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
谢谢
Varun Sareen
Thanks
Varun Sareen
推荐答案
要求服务提供商提供对默认情况下您存储文件的文件夹的访问权限tey不允许写功能
ask ur service provider to provide access rights to the folder where u r storing the file coz by default tey dont allow write facility
这篇关于通过C#.net2.0将文件上传到Web服务器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!