Tuesday, January 18, 2005

I'm currently doing some tests on an alpha version of Xceed FTP for .NET, supporting the Xceed FileSystem. It's so wonderful to be able to manipulate files and folders no mather where they reside. Take this generic directory listing method:

private static void DisplayListing( AbstractFolder folder )
{
  if( !folder.Exists )
  {
    Console.WriteLine( "\n  Folder {0} does not exist.\n", folder.FullName );
  }
  else
  {
    FileSystemItem[] items = folder.GetItems( false );
    long totalSize = 0;
    int fileCount = 0;
 
    Console.WriteLine( "\n  Folder listing of {0}\n", folder.FullName );
 
    foreach( FileSystemItem item in items )
    {
      Console.Write( "{0} {1} ", 
        item.LastWriteDateTime.ToShortDateString(),
        item.LastWriteDateTime.ToShortTimeString() );
 
      AbstractFile file = item as AbstractFile;
 
      if( file == null )
      {
        Console.Write( "            " );
      }
      else
      {
        Console.Write( "{0,16} ", file.Size.ToString( "N0" ) );
        totalSize += file.Size;
        ++fileCount;
      }
 
      Console.WriteLine( item.Name );
    }
 
    int folderCount = items.Length - fileCount;
 
    Console.WriteLine( "\n  {0} file{1}, {2} folder{3}, {4} bytes\n",
      fileCount.ToString(),
      ( fileCount == 1 ) ? string.Empty : "s",
      folderCount.ToString(),
      ( folderCount == 1 ) ? string.Empty : "s",
      totalSize.ToString() );
  }
}

As you can see, the code does not need to know what exactly is that AbstractFolder. People familiar with Xceed Zip for .NET already know we could call the above method like this:

DiskFolder folder = new DiskFolder( @"C:\Program Files\Microsoft SDKs\WinFX" );
DisplayListing( folder );

And obtain this kind of output:


  Folder listing of C:\Program Files\Microsoft SDKs\WinFX\
 24/11/2004   9:29 AM   <DIR>          bin
 24/11/2004   9:27 AM   <DIR>          Help
 24/11/2004   9:27 AM   <DIR>          License
 24/11/2004   9:27 AM   <DIR>          misc
 24/11/2004   9:29 AM   <DIR>          Setup
 24/11/2004   9:29 AM   <DIR>          VS Install Directory
 11/11/2004   6:03 PM           16,001 ReleaseNotes.htm
 12/01/2005   2:58 PM           17,297 SetEnv.cmd
  2 files, 6 folders, 33298 bytes

Or call the same method like this:

ZippedFolder folder = new ZippedFolder( 
  new DiskFile( @"D:\sample.zip" ), "ContMenuExt" );
DisplayListing( folder );

To get this output:


  Folder listing of \ContMenuExt\
 08/01/2001  11:29 AM            8,091 ContextMenu.cpp
 02/01/2001   4:15 PM            1,005 ContextMenu.h
 08/01/2001  11:32 AM            7,820 ContextMenuExt.cpp
 28/11/2000  11:23 AM              225 ContextMenuExt.def
 02/01/2001   5:02 PM            5,301 ContextMenuExt.dsp
 28/11/2000  11:23 AM              551 ContextMenuExt.dsw
 28/11/2000  11:23 AM              742 ContextMenuExt.h
 02/01/2001   4:12 PM            1,440 ContextMenuExt.rc
 08/01/2001   3:29 PM                2 ReadMe.txt
 02/01/2001   4:12 PM            1,195 resource.h
  10 files, 0 folders, 26372 bytes

With the upcoming version of Xceed FTP for .NET, it won't be more difficult to display the contents of a folder located on an FTP server:

FtpConnectionInfo info = new FtpConnectionInfo( "ftp.microsoft.com" );
FtpFolder folder = new FtpFolder( info );
DisplayListing( folder );

  Folder listing of \
 25/11/2002  12:00 AM   <DIR>          bussys
 21/05/2001  12:00 AM   <DIR>          deskapps
 20/04/2001  12:00 AM   <DIR>          developr
 18/11/2002  12:00 AM   <DIR>          KBHelp
 02/07/2002  12:00 AM   <DIR>          MISC
 16/12/2002  12:00 AM   <DIR>          MISC1
 25/02/2000  12:00 AM   <DIR>          peropsys
 02/01/2001  12:00 AM   <DIR>          Products
 04/04/2003  12:00 AM   <DIR>          PSS
 21/09/2000  12:00 AM   <DIR>          ResKit
 25/02/2000  12:00 AM   <DIR>          Services
 25/02/2000  12:00 AM   <DIR>          Softlib
  0 files, 12 folders, 0 bytes

As a mather of fact, stuff like this already works fine on my machine:

FtpConnectionInfo info = new FtpConnectionInfo( "ftp.cam.org", "***", "***" );
FtpFile ftpFile = new FtpFile( info, @"\pub\Photos.zip" );
 
if( ftpFile.Exists )
  ftpFile.Delete();
 
DiskFolder sourceFolder = new DiskFolder( @"E:\My Pictures\Clément\Petites" );
ZipArchive destFolder = new ZipArchive( ftpFile );
 
sourceFolder.CopyFilesTo( destFolder, true, true );
 
DisplayListing( destFolder );
DisplayListing( ftpFile.ParentFolder );

This is the output:


  Folder listing of \
 16/09/2004   9:39 AM           11,820 Buzz.jpg
 16/09/2004   9:40 AM           11,143 Chalet - Bercé.jpg
 16/09/2004   9:42 AM           15,749 Clément et Michel.jpg
 16/09/2004   9:43 AM           18,473 Clément et Papa.jpg
 16/09/2004   9:42 AM           15,004 Clément et Valérie.jpg
 14/02/2003   4:17 PM            7,984 clément1.jpg
 14/02/2003   4:18 PM           11,288 clément2.jpg
 14/02/2003   4:18 PM           10,648 clément3.jpg
 11/08/2004   3:25 PM           18,499 Famille.jpg
 11/08/2004   3:23 PM           36,734 Fier.jpg
 16/09/2004   9:40 AM           14,959 Grande discussion.jpg
 16/09/2004   9:41 AM           13,426 Maman et Clément.jpg
 11/08/2004   3:25 PM           24,594 Piscine.jpg
  13 files, 0 folders, 210321 bytes

  Folder listing of \pub\
 27/12/2004  11:06 AM            7,986 Builds du 2004-09-27.htm
 12/01/2005   4:13 PM          208,439 Clement.zip
 27/12/2004  11:06 AM            1,068 FileSystem.txt
 18/01/2005   2:44 PM          208,423 Photos.zip
 27/12/2004  11:06 AM   <DIR>          Second
 27/12/2004  11:06 AM           11,723 VSSWarning.jpg
 27/12/2004  11:06 AM          117,695 appnote.txt
 27/12/2004  11:06 AM               96 vssver.scc
  7 files, 1 folder, 555430 bytes

Am I the only one to find this cool? q;-)


FileSystem | FTP | Zip

1/18/2005 2:49:50 PM (Eastern Standard Time, UTC-05:00)  #   
Tracked by:
"mediale affari" (mediale affari) [Trackback]
"midi colonna sonore" (midi colonna sonore) [Trackback]
"londra big ben" (londra big ben) [Trackback]
"perline gioiello" (perline gioiello) [Trackback]
"Steve Brock Ministries" (Steve Brock Ministries) [Trackback]
"calendario 2003" (calendario 2003) [Trackback]
"gioco adulto gratis" (gioco adulto gratis) [Trackback]
"new york four seasons hotel" (new york four seasons hotel) [Trackback]
"immagini disney" (immagini disney) [Trackback]
"MUSIC - Bethlehem Morning" (MUSIC - Bethlehem Morning) [Trackback]
"giochi carta regolamento" (giochi carta regolamento) [Trackback]
"amministratore condominiale" (amministratore condominiale) [Trackback]
"freddissimo gradito papa" (freddissimo gradito papa) [Trackback]
"vacanza ad ischia" (vacanza ad ischia) [Trackback]
"memory card" (memory card) [Trackback]
"l attimo fuggente" (l attimo fuggente) [Trackback]
"albergo bournemouth" (albergo bournemouth) [Trackback]
"jhonny depp" (jhonny depp) [Trackback]
"bionde masturbandosi" (bionde masturbandosi) [Trackback]
"gioco scaricare gratis pc" (gioco scaricare gratis pc) [Trackback]
"torte bindi" (torte bindi) [Trackback]
"medio apparecchio" (medio apparecchio) [Trackback]
"Steve Brock Ministries" (Steve Brock Ministries) [Trackback]
"albergo firenze hotel" (albergo firenze hotel) [Trackback]
"PRODUCTS" (PRODUCTS) [Trackback]
"MUSIC - Gloria" (MUSIC - Gloria) [Trackback]
"Steve Brock Ministries" (Steve Brock Ministries) [Trackback]
"Steve Brock Ministries" (Steve Brock Ministries) [Trackback]
"MUSIC" (MUSIC) [Trackback]
"PARTNERS" (PARTNERS) [Trackback]
"Steve Brock Ministries" (Steve Brock Ministries) [Trackback]
"MUSIC - Mary Did You Know/What Child Is This?" (MUSIC - Mary Did You Know/What ... [Trackback]
"HOME" (HOME) [Trackback]
"PHOTOS" (PHOTOS) [Trackback]
"SCHEDULE" (SCHEDULE) [Trackback]
"OUTREACH" (OUTREACH) [Trackback]
"pulcino fottilo nella residenza" (pulcino fottilo nella residenza) [Trackback]
"CONTACT" (CONTACT) [Trackback]
"val d aosta" (val d aosta) [Trackback]
"scuola superiore" (scuola superiore) [Trackback]