C# 操作unix ftp失败
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上的程序有什么需要区别对待的地方吗?