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


C# FtpClient.MakeDirectory方法代码示例

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


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

示例1: CreateDirectory

 public static void CreateDirectory(IEnumerable<string> paths)
 {
     foreach (var path in paths) {
         var diskpath = Paths.Map(path);
         if (!Directory.Exists(diskpath)) {
             if (Paths.IsWritable(path)) Directory.CreateDirectory(diskpath);
             else if (CanUseFtp) {
                 using (var ftp = new FtpClient()) {
                     string dir, name;
                     ftp.Split(path, out dir, out name);
                     if (!dir.IsNullOrEmpty()) ftp.ChangeDirectory(dir);
                     ftp.MakeDirectory(name);
                     ftp.Close();
                 }
             } else throw new IOException(string.Format("Path {0} is write protected.", path));
         }
     }
 }
开发者ID:simonegli8,项目名称:Silversite,代码行数:18,代码来源:Files.cs

示例2: MakeDirectory

        public void MakeDirectory(string name)
        {
            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.MakeDirectory(name);
            }
            finally
            {
                ftp.Close();
            }
        }
开发者ID:chantsunman,项目名称:nUpdate,代码行数:22,代码来源:TransferService.cs

示例3: UploadPackage

        public void UploadPackage(string packagePath, string packageVersion)
        {
            if (!_hasAlreadyFixedStrings)
                FixProperties();

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

            try
            {
                _packageFtpClient.TransferProgress += TransferProgressChangedEventHandler;
                _packageFtpClient.PutFileAsyncCompleted += UploadPackageFinished;
                _packageFtpClient.Open(Username, Password.ConvertToUnsecureString());
                _packageFtpClient.ChangeDirectoryMultiPath(Directory);
                _packageFtpClient.MakeDirectory(packageVersion);
                _packageFtpClient.ChangeDirectory(packageVersion);
                _packageFtpClient.PutFileAsync(packagePath, FileAction.Create);
                _uploadPackageResetEvent.WaitOne();
            }
            finally
            {
                _packageFtpClient.Close();
                _uploadPackageResetEvent.Reset();
            }
        }
开发者ID:chantsunman,项目名称:nUpdate,代码行数:30,代码来源:TransferService.cs

示例4: InternalMoveContent

        public void InternalMoveContent(string directory, string aimPath)
        {
            foreach (FtpItem item in ListDirectoriesAndFiles(directory, false)
                .Where(
                    item => item.FullPath != aimPath && item.FullPath != aimPath.Substring(aimPath.Length - 1)))
            {
                FtpClient ftp = null;
                try
                {
                    ftp = new FtpClient(Host, Port, Protocol)
                    {
                        DataTransferMode = UsePassiveMode ? TransferMode.Passive : TransferMode.Active,
                        FileTransferType = TransferType.Binary,
                        Proxy = Proxy != null ? new HttpProxyClient(Proxy.Address.ToString()) : null
                    };
                    ftp.Open(Username, Password.ConvertToUnsecureString());

                    Guid guid; // Just for the out-reference of TryParse
                    if (item.ItemType == FtpItemType.Directory && UpdateVersion.IsValid(item.Name))
                    {
                        ftp.ChangeDirectoryMultiPath(aimPath);
                        if (!IsExisting(aimPath, item.Name))
                            ftp.MakeDirectory(item.Name);
                        ftp.ChangeDirectoryMultiPath(item.Name);

                        InternalMoveContent(item.FullPath, String.Format("{0}/{1}", aimPath, item.Name));
                        DeleteDirectory(item.FullPath);
                    }
                    else if (item.ItemType == FtpItemType.File &&
                             (item.Name == "updates.json" || Guid.TryParse(item.Name.Split('.')[0], out guid)))
                        // Second condition determines whether the item is a package-file or not
                    {
                        if (!IsExisting(aimPath, item.Name))
                        {
                            // "MoveFile"-method damages the files, so we do it manually with a work-around
                            //ftp.MoveFile(item.FullPath, String.Format("{0}/{1}", aimPath, item.Name));

                            string localFilePath = Path.Combine(Path.GetTempPath(), item.Name);
                            ftp.GetFile(item.FullPath, localFilePath, FileAction.Create);
                            ftp.PutFile(localFilePath, String.Format("{0}/{1}", aimPath, item.Name),
                                FileAction.Create);
                            File.Delete(localFilePath);
                        }
                        DeleteFile(item.ParentPath, item.Name);
                    }
                }
                finally
                {
                    if (ftp != null)
                        ftp.Close();
                }
            }
        }
开发者ID:chantsunman,项目名称:nUpdate,代码行数:53,代码来源:TransferService.cs


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