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


C# FtpClient.GetNameListing方法代码示例

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


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

示例1: DownloadBackup

 private static void DownloadBackup(string host, string user, string pwd, string ftpDownloadDir)
 {
     using (var ftp = new FtpClient())
     {
         ftp.Host = host;
         ftp.Credentials = new NetworkCredential { UserName = user, Password = pwd };
         ftp.Connect();
         foreach (var file in ftp.GetNameListing("/site/wwwroot/App_Data/Backup"))
         {
             using (var readStream = ftp.OpenRead(file, FtpDataType.Binary))
             using (var writeStream = File.Create(Path.Combine(ftpDownloadDir, Path.GetFileName(file))))
             {
                 readStream.CopyTo(writeStream);
             }
         }
     }
 }
开发者ID:kruglik-alexey,项目名称:jeegoordah,代码行数:17,代码来源:Program.cs

示例2: GetNameListing

        public static void GetNameListing() {
            using (FtpClient cl = new FtpClient()) {
                cl.Credentials = new NetworkCredential("ftp", "ftp");
                cl.Host = "ftp.example.com";
                cl.Connect();

                foreach (string s in cl.GetNameListing()) {
                    // load some information about the object
                    // returned from the listing...
                    bool isDirectory = cl.DirectoryExists(s);
                    DateTime modify = cl.GetModifiedTime(s);
                    long size = isDirectory ? 0 : cl.GetFileSize(s);

                    
                }
            }
        }
开发者ID:fanpan26,项目名称:Macrosage.Wx,代码行数:17,代码来源:GetNameListing.cs

示例3: UnsetOnlineStatus

        private bool UnsetOnlineStatus(FtpClient cl)
        {
            UserStatus onlineStatus = UserStatus.Unknown;
            try
            {
                string[] sa;
                sa = cl.GetNameListing(_ftpSkypeDir + _account);

                foreach (var iterateStatus in Enum.GetValues(typeof (UserStatus)))
                {
                    bool found = false;

                    foreach (var s in sa)
                    {
                        int indir;
                        if (int.TryParse(s.Substring(0,s.IndexOf(".", StringComparison.Ordinal)), out indir))
                        {
                            if (indir == (int) iterateStatus)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                    if (!found)
                    {
                        onlineStatus = (UserStatus) iterateStatus;
                        break;
                    }
                }

                if (cl.FileExists(_ftpSkypeDir + _account + "/current.png"))
                {
                    cl.Rename(_ftpSkypeDir + _account + "/current.png",
                        _ftpSkypeDir + _account + "/" + (int)onlineStatus + ".png");
                }
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
开发者ID:andbene72,项目名称:SkypeStatusChanger,代码行数:43,代码来源:FtpOnline.cs

示例4: _ftpDirectoryList

 private bool _ftpDirectoryList()
 {
     bool exists = true;
     try
     {
         using (FtpClient _ftpClient = new FtpClient())
         {
             Uri uri = new Uri(_folder, UriKind.Absolute);
             _ftpClient.Host = uri.Host;
             _ftpClient.Credentials = NetworkCredential;
             _ftpClient.Connect();
             ClearFiles();
             foreach (string file in _ftpClient.GetNameListing(uri.LocalPath))
                 AddFile(file);
         }
     }
     catch (Exception ex)
     {
         exists = false;
         Debug.WriteLine(ex, ex.Message);
     }
     return exists;
 }
开发者ID:jstarpl,项目名称:PlayoutAutomation,代码行数:23,代码来源:IngestDirectory.cs


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