Exemplo n.º 1
0
        public async void BuildFromFTP(string directory, FTPConnection connection)
        {
            try
            {
                string[] response = await connection.GetDirectoryContentsAsync(directory);

                for (int i = 0; i < response.Length; i++)
                {
                    FileSystemNode node = new FileSystemNode(response[i], directory, new FTPDetailParser());
                    if (node.IsDirectory)
                    {
                        this._internalDict.Add(Path.Combine(node.RelativeParentDirectory, node.Name),
                                               new FolderNode(node, FileBuildType.FTP, connection));
                    }
                    else
                    {
                        this._internalDict.Add(Path.Combine(node.RelativeParentDirectory, node.Name),
                                               node);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}");
                return;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor for the top FTP server directory. Use this one.
 /// </summary>
 /// <param name="connection"></param>
 public FolderNode(FTPConnection connection)
 {
     this.Modified                = default;
     this.Name                    = "httpdocs";
     this.IsDirectory             = true;
     this.RelativeParentDirectory = "/";
     SubdirectoyMap               = new FileSystemMap("/", FileSystemMap.FileBuildType.FTP, connection);
 }
Exemplo n.º 3
0
        public FileSystemMap(string directory, FileBuildType buildType, FTPConnection connection = null)
        {
            _internalDict = new Dictionary <string, FileSystemNode>();

            switch (buildType)
            {
            case FileBuildType.Local:
                BuildFromLocal(directory);
                break;

            case FileBuildType.FTP:
                BuildFromFTP(directory, connection);
                break;

            case FileBuildType.HTTP:
                throw new NotImplementedException();
                break;

            default:
                break;
            }
        }
Exemplo n.º 4
0
 public FolderNode(string lineFTPListDetail, string ftpListDirectory, FTPDetailParser parser, FTPConnection connection)
 {
     this.Modified                = parser.ParseModifiedDate(lineFTPListDetail);
     this.Name                    = parser.ParseFileName(lineFTPListDetail);
     this.IsDirectory             = true;
     this.RelativeParentDirectory = ftpListDirectory;
     this.Size                    = 0;
     SubdirectoyMap               = new FileSystemMap(Path.Combine(ftpListDirectory, Name), FileSystemMap.FileBuildType.FTP, connection);
 }
Exemplo n.º 5
0
 public FolderNode(FileSystemNode node, FileSystemMap.FileBuildType buildType, FTPConnection connection = null)
 {
     this.Name                    = node.Name;
     this.Modified                = node.Modified;
     this.IsDirectory             = true;
     this.RelativeParentDirectory = node.RelativeParentDirectory;
     this.Size                    = node.Size;
     SubdirectoyMap               = new FileSystemMap(Path.Combine(node.RelativeParentDirectory, Name), buildType, connection);
 }