Hi, After transferring PNG images to an FTP server, I am unable to open them as they are being corrupted. My code is as below:
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://... etc.");
request.UsePassive = true;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("username", "password");
StreamReader sourceStream = new StreamReader(fileLocalDir);
byte\[\] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
response.Close();
Another thing to add - when I download the file from the FTP server and open in IrfanView, the error below is displayed: "C:\Folder\file.png: Can't read file header! Unknown file format or file not found! (For unicode file names, please activate the Unicode PlugIn in 'Properties -> Languages')" Thanks for any assistance, Anthony.