0

我编写了一个桌面应用程序,将文件发布到我的网站

WebClient webclient = new WebClient();
webclient.UploadFileAsync(new Uri("http://mysite.com/getfile.aspx"),"POST", filename);

现在我需要创建一个名为 getfile.aspx 的页面来保存发布的图像。但我不知道如何访问发布的文件数据。

我不要求代码只需要知道如何访问发布的文件。

4

1 回答 1

1
            String imageURL = "xyz";
            String userName = "xyz";
            String password = "xyz";
            String destinationFolder = "xyz";
            Uri ftpSourceFilePath = new Uri(imageURL);

            if (ftpSourceFilePath.Scheme == Uri.UriSchemeHttp)
            {
                HttpWebRequest objRequest = (HttpWebRequest)HttpWebRequest.Create(ftpSourceFilePath);
                NetworkCredential objCredential = new NetworkCredential(userName, password);
                objRequest.Credentials = objCredential;
                objRequest.Method = WebRequestMethods.Ftp.DownloadFile;
                HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
                StreamReader objReader = new StreamReader(objResponse.GetResponseStream());
                int len = 0;
                int iProgressPercentage = 0;
                FileStream objFS = new FileStream((destinationFolder), FileMode.Create, FileAccess.Write, FileShare.Read);
                byte[] buffer = new byte[1024];
                while ((len = objReader.BaseStream.Read(buffer, 0, buffer.Length)) > 0)
                {

                    objFS.Write(buffer, 0, len);

                }
            }
于 2013-11-06T07:08:09.450 回答