Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.4k views
in .NET FTP by (160 points)
my windows form program can't put the chinese (DBCS) file name list
into listBox1 using ftpConnection1.GetFiles() method;



private void connectButton_Click(object sender, System.EventArgs e)
{
try
{ // Clear the list-box
listBox1.Items.Clear();

// Set server and log-in properties
ftpConnection1.ServerAddress = serverTextBox.Text;
ftpConnection1.ServerPort = int.Parse(portTextBox.Text);
ftpConnection1.UserName = userTextBox.Text;
ftpConnection1.Password = passwordTextBox.Text;

// Connect, get files and close
ftpConnection1.Connect();
ftpConnection1.ChangeWorkingDirectory("/1234567890/fmFSS");
listBox1.Items.AddRange(ftpConnection1.GetFiles());
ftpConnection1.Close();
}
catch (Exception ex)
{
if (ftpConnection1.IsConnected)
ftpConnection1.Close();
MessageBox.Show("Error");
}
}

3 Answers

0 votes
by (162k points)
Try setting the DataEncoding property to the appropriate encoding (big5?).
0 votes
by (160 points)
ftpConnection1.CommandEncoding = new UTF8Encoding(false);
ftpConnection1.DataEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
ftpConnection1.Connect();

I solved the problem.

I found the solution in forum but I don't know why ?
ftpConnection1.CommandEncoding = new UTF8Encoding(false);

who can explain why ?
0 votes
by (51.6k points)
UTF8 is a universal character encoding that supports all characters in all languages. It is becoming the standard. The reason Bruce suggested Big8 is that it's common for Chinese FTP servers to use that, but really UTF8 is better and will probably become the standard.

- Hans (EnterpriseDT)

Categories

...