Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in .NET FTP by (200 points)
Hy all,

I'm a newbie and I found a problem that I already saw described in others posts.

I'm trying change the Page Encode. I saw a solution in http://www.enterprisedt.com/forums/view ... oding#3172, but I think that in the version I'm working (1.2.3) some changes happened.

The FTPControlSockets.cs file looks diferent and, following the code, I found in line 319 the function InitStreams. There, throw the variable 'encoding', the Page Encode is being changed.

Well, I try the following:

_MyFTPClient As New Ftp.FTPClient
WindowsEncoding As System.Text.Encoding
_MyFTPClient.ControlEncoding = WindowsEncoding.GetEncoding("Windows-1252")
_MyFTPClient.RemoteHost = _MyFTPServer
_MyFTPClient.Connect()
_MyFTPClient.Login(_UserFTP, _PasswordFTP)

But the problem was no solved ...

Somebody has a clue?

Thanks an advance

Campelo

4 Answers

0 votes
by (200 points)
An observation:

I can create prefectly a Directory:

_MyFTPClient.MkDir("tradu
0 votes
by (51.6k points)
Are you sure that the server supports non-ASCII characters? Standard FTP does not, but many servers support some form of extended ASCII. The problem is that there are many different forms of extended ASCII.

Try logging into the server using a command-line FTP program, such as Microsoft's ftp.exe, and do a DIR to see what the server is returning. Also, if possible, log into the server directly (i.e. not using FTP) and get a directory listing of the actual file-system to see what the actual name of the directory is.

Finally, compile edtFTPnet in debug mode and set a break-point in FTPClient.Dir(string,bool) as shown with ** below:
   // a normal reply ... extract the file list
   string replyCode = lastValidReply.ReplyCode;
   if (!replyCode.Equals("450") && !replyCode.Equals("550") && !replyCode.Equals("226"))
   {
     // get a character input stream to read data from
     Encoding enc = controlEncoding == null ? Encoding.ASCII : controlEncoding;
**  StreamReader input = new StreamReader(data.DataStream, enc);
   
     // read a line at a time
     ArrayList lines = new ArrayList(10);


When you reach the breakpoint, see what enc.EncodingName is. It should be whatever you set FTPClient.ControlEncoding to.

I just realized that you're using FTPClient rather than FTPConnection. Please use the latter since this is the interface we're maintaining. The FTPClient class will be obsoleted soon.

- Hans (EDT)
0 votes
by (200 points)
Hy Hans,

your wisdom was very useful!

First, I changed all the code to work with FTPConnection.

Second, just one observation:
the file FTPClient.cs, in the line 2472 (v 1.2.3) doesn't have the line
Encoding enc = controlEncoding == null ? Encoding.ASCII : controlEncoding;

I put there and add the 'enc' parameter in the constructor of StreamReader.

Now all is working perfectly.

Thanks Hans!
0 votes
by (51.6k points)
Oh yes, I didn't realize the current version of edtFTPnet is so old. We'll release an update soon.

- Hans (EDT)

Categories

...