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


C# FtpClient.DeleteFile方法代码示例

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


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

示例1: DeleteFile

 public static void DeleteFile() {
     using (FtpClient conn = new FtpClient()) {
         conn.Host = "localhost";
         conn.Credentials = new NetworkCredential("ftptest", "ftptest");
         conn.DeleteFile("/full/or/relative/path/to/file");
     }
 }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:7,代码来源:DeleteFile.cs

示例2: DeleteFile

        public void DeleteFile(string fileName)
        {
            using (var ftpClient = new FtpClient())
            {
                ftpClient.Host = _host;
                ftpClient.DataConnectionType = FtpDataConnectionType.AutoActive;
                ftpClient.Credentials = new NetworkCredential(_username, _password);

                ftpClient.Connect();
                // ftpClient.CreateDirectory("/test");
                ftpClient.SetWorkingDirectory(_folder);

                ftpClient.DeleteFile(_folder + ((_folder == "/") ? "" : "/") + fileName);

                ftpClient.Disconnect();
            }
        }
开发者ID:markashleybell,项目名称:microwiki,代码行数:17,代码来源:RemoteFileManager.cs

示例3: Delete

 public static void Delete(IEnumerable<string> paths)
 {
     paths.Each(path => {
         if (path.Contains("*")) All(path).Each(p => Delete(p));
         path = Paths.Normalize(path);
         var ftppath = path.Substring(1);
         var diskpath = Paths.Map(path);
         if (Directory.Exists(diskpath)) {
             if (Paths.IsWritable(path)) {
                 try {
                     Directory.Delete(diskpath, true);
                 } catch {
                     var info = new DirectoryInfo(diskpath);
                     var children = info.EnumerateFileSystemInfos("*", SearchOption.AllDirectories).ToList();
                     foreach (var file in children.OfType<FileInfo>()) File.Delete(file.FullName);
                     children.Reverse();
                     foreach (var dir in children.OfType<DirectoryInfo>()) Directory.Delete(dir.FullName);
                 }
             } else if (CanUseFtp) {
                 using (var ftp = new FtpClient()) {
                     ftp.DeleteDirectoryRecursive(ftppath);
                     ftp.Close();
                 }
             } else throw new IOException(string.Format("Path {0} is write protected.", path));
         } else if (File.Exists(diskpath)) {
             if (Paths.IsWritable(path)) File.Delete(diskpath);
             else if (CanUseFtp) {
                 using (var ftp = new FtpClient()) {
                     string dir, name;
                     ftp.Split(path, out dir, out name);
                     ftp.ChangeDirectory(dir);
                     ftp.DeleteFile(name);
                     ftp.Close();
                 }
             } else throw new IOException(string.Format("Path {0} is write protected.", path));
         }
     });
 }
开发者ID:simonegli8,项目名称:Silversite,代码行数:38,代码来源:Files.cs

示例4: downloadFile

        private static void downloadFile(FtpClient client, FtpListItem file, bool deleteFtpFile)
        {
            string destinationPath = String.Format(@"{0}\{1}", Directory.GetCurrentDirectory(), file.Name);

            using (var ftpStream = client.OpenRead(file.FullName)) {
                using (var fileStream = File.Create(destinationPath, (int)ftpStream.Length)) {
                    var buffer = new byte[8 * 1024];
                    int count;
                    while ((count = ftpStream.Read(buffer, 0, buffer.Length)) > 0) {
                        fileStream.Write(buffer, 0, count);
                    }
                }
            }
            DownloadedFile temp = new DownloadedFile();
            temp.originalPath = file.FullName;
            temp.fullOriginalPath = client.Host + file.FullName;
            temp.finalPath = destinationPath;
            temp.name = file.Name;
            temp.extension = ".txt";
            minervaFiles.Add(temp);
            if (deleteFtpFile) {
                client.DeleteFile(file.FullName);
            }
        }
开发者ID:robertmcconnell2007,项目名称:CCCommunications,代码行数:24,代码来源:Program.cs

示例5: DeleteFile

        public void DeleteFile(string fileName)
        {
            if (!_hasAlreadyFixedStrings)
                FixProperties();

            var ftp = new FtpClient(Host, Port, Protocol)
            {
                DataTransferMode = UsePassiveMode ? TransferMode.Passive : TransferMode.Active,
                FileTransferType = TransferType.Binary,
                Proxy = Proxy != null ? new HttpProxyClient(Proxy.Address.ToString()) : null
            };

            try
            {
                ftp.Open(Username, Password.ConvertToUnsecureString());
                ftp.ChangeDirectoryMultiPath(Directory);
                ftp.DeleteFile(fileName);
            }
            finally
            {
                ftp.Close();
            }
        }
开发者ID:chantsunman,项目名称:nUpdate,代码行数:23,代码来源:TransferService.cs

示例6: ClearFiles

        private void ClearFiles(FtpClient ftpClient, string remoteDir) {
            if(ftpClient.DirectoryExists(remoteDir) == false)
                return;

            foreach(var file in Client.ListDirectoryDetail(remoteDir).GetFiles()) {
                ftpClient.DeleteFile(file.FullName);
            }
        }
开发者ID:debop,项目名称:NFramework,代码行数:8,代码来源:FtpClientFixture.cs


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