当前位置: 首页>>代码示例>>C#>>正文


C# FtpClient.DeleteDirectory方法代码示例

本文整理汇总了C#中FtpClient.DeleteDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# FtpClient.DeleteDirectory方法的具体用法?C# FtpClient.DeleteDirectory怎么用?C# FtpClient.DeleteDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FtpClient的用法示例。


在下文中一共展示了FtpClient.DeleteDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteDirectory

 public static void DeleteDirectory() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         
         // Remove the directory and all objects beneath it. The last parameter
         // forces System.Net.FtpClient to use LIST -a for getting a list of objects
         // beneath the specified directory.
         conn.DeleteDirectory("/path/to/directory", true, 
             FtpListOption.AllFiles | FtpListOption.ForceList);
     }
 }
开发者ID:Kylia669,项目名称:DiplomWork,代码行数:12,代码来源:DeleteDirectory.cs

示例2: BeginCreateDirectory

        public static void BeginCreateDirectory() {
            // The using statement here is OK _only_ because m_reset.WaitOne()
            // causes the code to block until the async process finishes, otherwise
            // the connection object would be disposed early. In practice, you
            // typically would not wrap the following code with a using statement.
            using (FtpClient conn = new FtpClient()) {
                m_reset.Reset();
        
                conn.Host = "localhost";
                conn.Credentials = new NetworkCredential("ftptest", "ftptest");
                conn.DeleteDirectory("/test", true);
                conn.BeginCreateDirectory("/test/path/that/should/be/created", true,
                    new AsyncCallback(CreateDirectoryCallback), conn);

                m_reset.WaitOne();
                conn.Disconnect();
            }
        }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:18,代码来源:BeginCreateDirectory.cs

示例3: DeleteDirectory

        public void DeleteDirectory(string directoryPath)
        {
            if (!_hasAlreadyFixedStrings)
                FixProperties();

            var ftp = new FtpClient(Host, Port, Protocol);
            try
            {
                IEnumerable<FtpItem> items = ListDirectoriesAndFiles(directoryPath, true);
                ftp.DataTransferMode = UsePassiveMode ? TransferMode.Passive : TransferMode.Active;
                ftp.FileTransferType = TransferType.Binary;
                ftp.Proxy = Proxy != null ? new HttpProxyClient(Proxy.Address.ToString()) : null;
                ftp.Open(Username, Password.ConvertToUnsecureString());
                foreach (FtpItem item in items)
                {
                    switch (item.ItemType)
                    {
                        case FtpItemType.Directory:
                            DeleteDirectory(String.Format("/{0}/{1}/", directoryPath, item.Name));
                            break;
                        case FtpItemType.File:
                            DeleteFile(directoryPath, item.Name);
                            break;
                    }
                }
                ftp.DeleteDirectory(directoryPath);
            }
            finally
            {
                ftp.Close();
            }
        }
开发者ID:chantsunman,项目名称:nUpdate,代码行数:32,代码来源:TransferService.cs


注:本文中的FtpClient.DeleteDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。