예제 #1
0
 public FtpStorageFolder(string folder, FtpListItem ftpItem)
 {
     DateCreated = ftpItem.RawCreated < DateTime.FromFileTimeUtc(0) ? DateTimeOffset.MinValue : ftpItem.RawCreated;
     Name        = ftpItem.Name;
     Path        = PathNormalization.Combine(folder, ftpItem.Name);
     FtpPath     = FtpHelpers.GetFtpPath(Path);
 }
예제 #2
0
 public FtpStorageFolder(FtpItem ftpItem)
 {
     DateCreated = ftpItem.ItemDateCreatedReal;
     Name        = ftpItem.ItemName;
     Path        = ftpItem.ItemPath;
     FtpPath     = FtpHelpers.GetFtpPath(ftpItem.ItemPath);
 }
예제 #3
0
        public override IAsyncOperation <IStorageItem> GetItemAsync(string name)
        {
            return(AsyncInfo.Run <IStorageItem>(async(cancellationToken) =>
            {
                using var ftpClient = new FtpClient();
                ftpClient.Host = FtpHelpers.GetFtpHost(Path);
                ftpClient.Port = FtpHelpers.GetFtpPort(Path);
                ftpClient.Credentials = FtpManager.Credentials.Get(ftpClient.Host, FtpManager.Anonymous);

                if (!await ftpClient.EnsureConnectedAsync())
                {
                    return null;
                }

                var item = await ftpClient.GetObjectInfoAsync(FtpHelpers.GetFtpPath(PathNormalization.Combine(Path, name)));
                if (item != null)
                {
                    if (item.Type == FtpFileSystemObjectType.File)
                    {
                        return new FtpStorageFile(Path, item);
                    }
                    else if (item.Type == FtpFileSystemObjectType.Directory)
                    {
                        return new FtpStorageFolder(Path, item);
                    }
                }
                return null;
            }));
        }
예제 #4
0
 public FtpStorageFile(string path, string name, DateTimeOffset dateCreated)
 {
     Path        = path;
     Name        = name;
     FtpPath     = FtpHelpers.GetFtpPath(path);
     DateCreated = dateCreated;
 }
예제 #5
0
 public FtpStorageFolder(IStorageItemWithPath item)
 {
     Name    = System.IO.Path.GetFileName(item.Path);
     Path    = item.Path;
     FtpPath = FtpHelpers.GetFtpPath(item.Path);
 }
예제 #6
0
 public FtpStorageFile(IStorageItemWithPath item)
 {
     Path    = item.Path;
     Name    = IO.Path.GetFileName(item.Path);
     FtpPath = FtpHelpers.GetFtpPath(item.Path);
 }