C# 操作unix ftp失败

ladofwind 2010-03-23 05:52:05
FtpWebRequest request = this.CreateRequest(filedir);
request.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = null;
try
{
response = (FtpWebResponse)request.GetResponse();
if(response !=null)
response.Close();
}
catch (WebException we1)
{
if (we1.Status == WebExceptionStatus.ProtocolError)
{
//命令错误
}
if(response !=null)
response.Close();
//此时没有该目录,需要创建
request = this.CreateRequest(filedir);
request.Method = WebRequestMethods.Ftp.MakeDirectory;
try
{
response = (FtpWebResponse)request.GetResponse();
}
catch (WebException e)
{
throw new IOException("创建目录失败!"+e.Message);
}


filedir是我要创建的目录,先用listdirectory来看是否有目录,如果没有则创建,在windows上一切正常,
可是在Sun的unix服务器上,filedir这个目录存在的情况下,listdirectory也报异常,走入创建目录的分支,
导致程序崩溃,报出创建目录失败的错误,请问C#在windows,unix上的程序有什么需要区别对待的地方吗?

...全文
67 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,536

社区成员

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

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

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