Ftp上传时为什么文件名为中文就上传不了(请做过基于Ftp协议上传的大侠进来看一下)

Octer 2004-05-12 09:22:32
C#中Ftp上传时为什么文件名为中文就上传不了
错误提示:
550 ??.rar: The filename, directory name, or volume label syntax is incorrect.
整个执行Ftp服务器的返回信息:
220 fyrjs-wyb Microsoft FTP Service (Version 5.0).
220 fyrjs-wyb Microsoft FTP Service (Version 5.0).
USER fyrjs
331 Password required for fyrjs.
331 Password required for fyrjs.
PASS xxx
230-;6S-7CNJ1>FTP
230 User fyrjs logged in.
230 User fyrjs logged in.
Connected to 192.168.100.11
200 Type set to A.
200 Type set to A.
227 Entering Passive Mode (192,168,100,11,4,244).
227 Entering Passive Mode (192,168,100,11,4,244).
550 ??.rar: The filename, directory name, or volume label syntax is incorrect.
550 ??.rar: The filename, directory name, or volume label syntax is incorrect.
...全文
851 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Octer 2004-06-17
  • 打赏
  • 举报
回复
正如楼上几位说的,我已经解决了
呵呵!
的确是编码的问题
Byte[] cmdBytes=System.Text.Encoding.GetEncoding("GB2312").GetBytes((command+"\r\n").ToCharArray());
greatsft 2004-06-13
  • 打赏
  • 举报
回复
是编码问题,可以用通用unicode编码

wish u good luck
Greatsft
zklvy 2004-06-13
  • 打赏
  • 举报
回复
估计你的代码是参考国外的,所以,你要设置一下向ftp服务器发送命令的那段程序:
//向FTP服务器发送命令
private void sendCommand(String command)
{

//原来是Encoding.ASCII.GetBytes(....)
Byte[] cmdBytes = Encoding.Default.GetBytes((command+"\r\n").ToCharArray());
clientSocket.Send(cmdBytes, cmdBytes.Length, 0);
readReply();
}
Hexin5050 2004-05-12
  • 打赏
  • 举报
回复
System.Test.Encoding.Default.GetString(....)

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧