コード例 #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);
 }