Example #1
0
 public override void list(string path, CallbackOnList callback = null)
 {
     try
     {
         if (this.connect())
         {
             this.client.ChangeDirectory(path);
             foreach (var entry in client.ListDirectory("."))
             {
                 if (callback != null)
                 {
                     if (entry.Name != "." && entry.Name != "..")
                     {
                         callback(new DirInfo()
                         {
                             name  = entry.Name,
                             full  = entry.FullName,
                             isdir = entry.IsDirectory,
                             ext   = System.IO.Path.GetExtension(entry.Name),
                             path  = path
                         });
                     }
                 }
             }
             this.disconnect();
         }
     }
     catch (Exception error) {
         if (this.log != null)
         {
             this.log(error.Message.ToString());
         }
     }
 }
Example #2
0
        public void list(string path, CallbackOnList callback = null)
        {
            var driver = this.getDriver();

            if (driver != null)
            {
                driver.list(path, callback);
            }
        }
Example #3
0
        public override void list(string path, CallbackOnList callback = null)
        {
            StreamReader reader = null;

            try
            {
                if (this.connect(path))
                {
                    request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                    reader         = new StreamReader(request.GetResponse().GetResponseStream());
                }
            }
            catch (Exception error)
            {
                reader = null;
                if (this.log != null)
                {
                    this.log(error.Message.ToString());
                }
            }
            if (reader != null && callback != null)
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    string name = line.Substring(line.LastIndexOf(" ") + 1);


                    if (callback != null)
                    {
                        callback(new DirInfo()
                        {
                            name = name,
                            full = path + name,
                            ext  = System.IO.Path.GetExtension(name),
                            //  isdir = this.exists(path + name), //... lenta
                            isdir = (System.IO.Path.GetExtension(name) == string.Empty),  //... rapida no segura
                            path  = path
                        });
                    }
                }
            }
        }
Example #4
0
 public abstract void list(string path, CallbackOnList callback = null);