使用C#的FTP上传类,上传英文名称的文件都可以上传,可是上传中文名的文件的时候,就报550错误!急求解决方案! 上传代码如下:
/// <summary>
/// 上传一个文件
/// </summary>
/// <param name="strFileName">本地文件名</param>
public void Put(string strFileName)
{
if (!bConnected)
{
Connect();
}
Socket socketData = CreateDataSocket();
SendCommand("TYPE I");
if (iReplyCode != 200)
{
throw new IOException(strReply.Substring(4));
}
SendCommand("STOR " + Path.GetFileName(strFileName));
if (!(iReplyCode == 125 || iReplyCode == 150))
{
throw new IOException(strReply.Substring(4));
}
FileStream input = new FileStream(strFileName, FileMode.Open);
int iBytes = 102400;
while ((iBytes = input.Read(buffer, 0, buffer.Length)) > 0)
{
socketData.Send(buffer, iBytes, 0);
}
input.Close();
if (socketData.Connected)
{
socketData.Close();
}
ReadReply();
//if (!(iReplyCode == 226 || iReplyCode == 250))
//{
// ReadReply();
// if (!(iReplyCode == 226 || iReplyCode == 250))
// {
// throw new IOException(strReply.Substring(4));
// }
//}
}
- 2 回答
- 0 关注
- 968 浏览
添加回答
举报
0/150
提交
取消