将文件从C#桌面应用程序上传到网站文件夹 [英] Upload File from C# Desktop Application to Website Folder

查看:185
本文介绍了将文件从C#桌面应用程序上传到网站文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

君子;我正在尝试将文件上传到我的网站用户图像上的文件夹。我使用以下代码:

Gentleman; I am trying to upload a file to folder on my website "User Images". I am using the following code:

WebClient myWebClient = new WebClient();
           string fileName = theFile.Text;
           string Uri = "My Website/User_Images";
           byte[] responseArray = myWebClient.UploadFile(Uri, fileName);





它返回以下错误:

{远程服务器返回错误:(405)方法不允许。}



我认为有可能存在某种类型的登录以获得上传许可,但是我在这里和一般都做了一些搜索,我找不到我要找的东西。有人能为我提供一个代码示例,我可以用它来解决这个看似简单的问题吗?谢谢您的帮助。 Pat



It is returning the following error:
{"The remote server returned an error: (405) Method Not Allowed."}

I suppose it makes sense that there might be some type of "log in" for permission to do the upload, but I have done some searches both here and in general and I cannot find what I am looking for. Can someone supply me with a code example that I can use to resolve this seeming simple problem? Thank you for your help. Pat

推荐答案

您是否尝试过设置凭据?



WebClient.Credentials Property [ ^ ]
Have you tried to set the credentials?

WebClient.Credentials Property[^]


这篇关于将文件从C#桌面应用程序上传到网站文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆