Dart.Ftp Namespace > Ftp Class : Encoding Property |
public void InitConnection(object state) { //Connect to the FTP server. ftp1.Connect(); //Use UTF8 if available. //NOTE: Some servers require the user to be authenticated before UTF8 support can be enabled, //if that is true then the following line must be called after the call to ftp1.Authenticate(); UseUTF8(); //Authenticate the user. ftp1.Authenticate(); //Send the CCC command. UseCCC(); } public void UseUTF8() { //Check the feeatures property to see if the server supports UTF8 encoding. if (ftp1.Features.Utf8Encoding) { //If the server supports UTF8 encoding, send the UTF8 command as specified in RFC2640. //Some servers (such as Filezilla) do not explicitly require this command but others (such as IIS) do. Response Resp = ftp1.Send("OPTS UTF8 ON"); if (Resp.Code < 299) //If the OPTS UTF8 ON command succeeded then set the connection encoding appropriately. ftp1.Encoding = System.Text.Encoding.UTF8; } } public void UseCCC() { //Send the CCC command Response Resp = ftp1.Send("CCC"); //Check the response to see if the CCC command was successful. if (Resp.Code < 299) //Shutdown the SSL layer of the control connection. This command leaves the underlying unencrypted TCP connection open. ftp1.Connection.ShutdownSsl(); }
Public Sub InitConnection(ByVal state As Object) 'Connect to the FTP server. ftp1.Connect() 'Use UTF8 if available. 'NOTE: Some servers require the user to be authenticated before UTF8 support can be enabled, 'if that is true then the following line must be called after the call to ftp1.Authenticate(); UseUTF8() 'Authenticate the user. ftp1.Authenticate() 'Send the CCC command. UseCCC() End Sub Public Sub UseUTF8() 'Check the feeatures property to see if the server supports UTF8 encoding. If ftp1.Features.Utf8Encoding Then 'If the server supports UTF8 encoding, send the UTF8 command as specified in RFC2640. 'Some servers (such as Filezilla) do not explicitly require this command but others (such as IIS) do. Dim Resp As Response = ftp1.Send("OPTS UTF8 ON") If Resp.Code < 299 Then 'If the OPTS UTF8 ON command succeeded then set the connection encoding appropriately. ftp1.Encoding = System.Text.Encoding.UTF8 End If End If End Sub Public Sub UseCCC() 'Send the CCC command Dim Resp As Response = ftp1.Send("CCC") 'Check the response to see if the CCC command was successful. If Resp.Code < 299 Then 'Shutdown the SSL layer of the control connection. This command leaves the underlying unencrypted TCP connection open. ftp1.Connection.ShutdownSsl() End If End Sub