Hello,
First sorry if it's not the right section, but i didn't found a section with C#.
Second, as usual sorry for my english
I making an application that needs to upload files, screens, etc to my team's server.
I can upload files like, .txt, .php etc but when i want to upload an image (jpg), the image on the server is not valid.
When i upload i got the message, 226 Transfert complete. So the upload seems to be ok... but not...
Example of the imagefile code before upload:
Example of the imagefile code after upload:
I upload files on ftp with this C# code:
I also tried to change "Encoding.UTF8.GetBytes(....)" whith Encoding.ASCII ... Encoding.Unicode... but nothing end with the same code after upload.
But if I try to upload a txt file with "test etc" as line 1, it uploads correctly and i got a txt file with "test etc" ...
What is wrong?
Thx in advance for your help.
First sorry if it's not the right section, but i didn't found a section with C#.
Second, as usual sorry for my english
I making an application that needs to upload files, screens, etc to my team's server.
I can upload files like, .txt, .php etc but when i want to upload an image (jpg), the image on the server is not valid.
When i upload i got the message, 226 Transfert complete. So the upload seems to be ok... but not...
Example of the imagefile code before upload:
Example of the imagefile code after upload:
I upload files on ftp with this C# code:
CSHARP Code
- private void FtpUploadScreen(Uri uri, string fileName, Bitmap screen, ImageFormat fileFormat)
- {
- // Get the object used to communicate with the server.
- FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri + "/" + fileName);
-
- request.Method = WebRequestMethods.Ftp.UploadFile;
-
- request.UseBinary = true;
- request.Credentials = new NetworkCredential(this.TB_FtpLogin.Text, this.FtpSecurePass(this.TB_FtpPass.Text));
- request.KeepAlive = false;
- request.UsePassive = false;
- request.Timeout = 10000;
-
- screen.Save(this.AppDir + this.TempDir + "\\" + fileName, fileFormat);
-
-
- 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();
-
- //MessageBox.Show("Upload File Complete, status " + response.StatusDescription);
-
- response.Close();
-
- File.Delete(this.AppDir + this.TempDir + "\\" + fileName);
- }
I also tried to change "Encoding.UTF8.GetBytes(....)" whith Encoding.ASCII ... Encoding.Unicode... but nothing end with the same code after upload.
But if I try to upload a txt file with "test etc" as line 1, it uploads correctly and i got a txt file with "test etc" ...
What is wrong?
Thx in advance for your help.