![]() ![]() The most trivial way to upload a binary file to an FTP server using. C# WEBCLIENT FILE CREDENTIALS ZIP FILEexcept when I try to unzip the downloaded ZIP file I get an invalid ZIP file. ReadCount = responseStream.Read(buffer, 0, bufferSize) Ģ) Everything seems to work. Using (FileStream writer = new FileStream(localFilename, FileMode.Create)) Using (StreamReader reader = new StreamReader(responseStream)) Using (Stream responseStream = response.GetResponseStream()) Using (FtpWebResponse response = (FtpWebResponse)request.GetResponse()) This seems to work, in that I get a file on the server of the right size.ġ) How do I stream it, rather than load it into memory first? I will be uploading very large files.Īnd for downloading I have using (WebClient client = new WebClient())įtpWebRequest request = (FtpWebRequest)WebRequest.Create(remoteFile) Response = (FtpWebResponse)request.GetResponse() RequestStream.Write(fileContents, 0, fileContents.Length) Using (Stream requestStream = request.GetRequestStream()) Request.ContentLength = fileContents.Length Using (StreamReader sourceStream = new StreamReader(LocalFilePath))įileContents = (sourceStream.ReadToEnd()) Request.Credentials = new NetworkCredential(MyLogin, MyPassword) ![]() I am trying to upload and then download a ZIP file to (my) server.įor uploading I have using (WebClient client = new WebClient())įtpWebRequest request = (FtpWebRequest)WebRequest.Create(MyUrl) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |