使用C#将文件上传到Web服务器(使用HTTP)

问题描述:

我正在尝试使用C#将网站自动上传到网站
例如,我正在尝试为http://www.fileflyer.com/default.aspx、http://multiupload.com、shareflare、letitbit等网站创建自动上传器. 该网站要求用户检查我同意服务条款",并要求他输入电子邮件.

PS我搜索了一下互联网,发现 [ ^ ].
但是,它不能与multiupload和fileflyer一起使用(这对我来说很重要).
谁能给我一个小例子或有关此的一些信息吗?一个例子将是完美的
亚当·亚当(Adam)谨此感谢.

I''m trying to make an auto uploader to websites with C#
For instance, I''m trying to create an auto uploader for websites like http://www.fileflyer.com/default.aspx, http://multiupload.com, shareflare, letitbit etc...
The website asks the user to check the "I agree to Terms of Service" and asks him to enter an email.

P.S I searched the internet a bit and I found this[^].
However, it did not work with multiupload and fileflyer (which are fundamental for me to accomplish this).
Can anyone give me a small example or some info about that? an example would be perfect
Thanks from advance, Adam.

您必须在目标站点中查找API,也许是Web服务!
然后将其包含在您的项目中,然后阅读其文档以进行配置!
但是,如果您只想将文件上传到服务器,请使用以下代码段:
you have to look up for API in your target sites, a web service maybe!
then include it in your projects, and then read their documents to config!
but if you want just upload file to server use this code snippet:
private void SaveTToWeb()
{
    try
    {
        //create WebClient object
        WebClient client = new WebClient();
        string myFile = @"C:\file.txt";
        client.Credentials = CredentialCache.DefaultCredentials;
        client.UploadFile(@"http://myweb.com/projects/idl/Draft Results/RK/myFile", "PUT", myFile);
        client.Dispose();
    }
    catch (Exception err)
    {
        MessageBox.Show(err.Message);
    }
}


如果要使用ftp,请阅读以下内容:
C#ftp上传 [


and if you want to use ftp, read this:
C# ftp upload[^]