1

I am trying to upload files created from string text to my ftp server, but I'm having an encoding problem :

Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://ftp.myserver.com/" & Now.Day & Now.Month & Now.Year & Now.Hour & Now.Minute & ".txt"), System.Net.FtpWebRequest)
request.Credentials = New System.Net.NetworkCredential("myusername", "mypassword")
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

Dim File() As Byte = System.Text.Encoding.ASCII.GetBytes(log)
Dim strZ As System.IO.Stream = request.GetRequestStream()
strZ.Write(File, 0, File.Length)
strZ.Close()
strZ.Dispose()

the log variable being a string, i tried ascii/utf8/unicode when converting the string to the array of bytes, but still, the files uploaded to the ftp don't show a lot of characters like "é", anyone can help me please?

T.S.
  • 18,195
  • 11
  • 58
  • 78
user3781458
  • 71
  • 1
  • 2
  • 8
  • Binary transfer as here; http://stackoverflow.com/questions/3576436/upload-a-file-with-encoding-using-ftp-in-c-sharp – Alex K. Jul 17 '15 at 11:26
  • thank you, i didn't know about the binary option when uploading ftp files – user3781458 Jul 17 '15 at 11:52
  • Don't use Ascii encoding. It removes all non printable characters. Use UTF8 encoding instead. If you have character which are > 256 these are Unicode character so you must use Encoding.Unicode. – jdweng Jul 18 '15 at 12:03

0 Answers0