日期:2014-05-18 浏览次数:21041 次
/// <summary> /// 删除文件 /// </summary> /// <param name="path">路径</param> /// <param name="cred">通行证</param> /// <returns></returns> public static bool FtpDeleteFile(string path, ICredentials cred) { FtpWebRequest req = (FtpWebRequest)WebRequest.Create(path); if (cred != null) req.Credentials = cred; req.Method = WebRequestMethods.Ftp.DeleteFile; req.KeepAlive = false; try { req.GetResponse().Close(); return true; } catch (WebException ex) { log.Error("FtpDeleteFile Error:" + ex.Message); return false; } }
------解决方案--------------------
去下载个FTPclient的类.
就是一个类文件.很好用的.
里边提供了很多方法.包括你所要的删除