C# 判断ftp上目录是否存在
C#控制ftp,需要完成这样一个功能:判断一个目录是否存在,不存在则创建该目录,存在则不创建。...
C#
控制ftp,
需要完成这样一个功能:
判断一个目录是否存在,不存在则创建该目录,存在则不创建。 展开
控制ftp,
需要完成这样一个功能:
判断一个目录是否存在,不存在则创建该目录,存在则不创建。 展开
2个回答
2013-04-15
展开全部
FtpWebRequest frequest = FtpWebRequest.Create(" ftp://guoming.daya.com:1212/test") as FtpWebRequest; frequest.Credentials = new NetworkCredential("用户名", "密码"); frequest.Method = WebRequestMethods.Ftp.ListDirectory; try { FtpWebResponse response = frequest.GetResponse() as FtpWebResponse; } catch { Console.WriteLine("目录不存在"); } 答案补充 重复以上操作就可以了啊
FtpWebRequest frequest = FtpWebRequest.Create("ftp://guoming.daya.com:1212/test/test") as FtpWebRequest;
frequest.Credentials = new NetworkCredential("用户名", "密码");
frequest.Method = WebRequestMethods.Ftp.MakeDirectory;
try
{
FtpWebResponse response = frequest.GetResponse() as FtpWebResponse;
}
catch
{
} 答案补充 FtpWebRequest frequest = FtpWebRequest.Create("ftp://guoming.daya.com:1212/test/test/test") as FtpWebRequest;
frequest.Credentials = new NetworkCredential("用户名", "密码");
frequest.Method = WebRequestMethods.Ftp.MakeDirectory;
try
{
FtpWebResponse response = frequest.GetResponse() as FtpWebResponse;
}
catch
{
} 答案补充 暂时没有好的解决方法。
FtpWebRequest frequest = FtpWebRequest.Create("ftp://guoming.daya.com:1212/test/test") as FtpWebRequest;
frequest.Credentials = new NetworkCredential("用户名", "密码");
frequest.Method = WebRequestMethods.Ftp.MakeDirectory;
try
{
FtpWebResponse response = frequest.GetResponse() as FtpWebResponse;
}
catch
{
} 答案补充 FtpWebRequest frequest = FtpWebRequest.Create("ftp://guoming.daya.com:1212/test/test/test") as FtpWebRequest;
frequest.Credentials = new NetworkCredential("用户名", "密码");
frequest.Method = WebRequestMethods.Ftp.MakeDirectory;
try
{
FtpWebResponse response = frequest.GetResponse() as FtpWebResponse;
}
catch
{
} 答案补充 暂时没有好的解决方法。
2013-04-15
展开全部
当然可以啊,利用IO来实现。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询