FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Database
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
August 02, 2006
Synchronize Now!

Synchronizing files with .NET 2.0, S3, and FTP

(Page 1 of 5)
Eric Bergman-Terrell
Eric uses Amazon.com's S3 web service and .NET 2.0's FtpWebRequest class to securely synchronize files on multiple machines.
Eric has developed everything from data-reduction software for particle bombardment experiments to software for travel agencies. He can be contacted at EricTerrell@comcast.net.


There are several files I need to access and update from practically any computer I use—my web browser favorites, contact lists, web-site passwords, and my .NET programming tips. Although I keep these files on a flash drive, it's not always convenient to take the drive everywhere I go. I'd rather store the files on a server and access them over the Internet, as long as it's reliable, secure, and inexpensive. Xdrive.com offers 5 GB of Internet-accessible storage, but the $10.00 monthly fee is more than I pay for hosting my entire web site. Fortunately, Amazon's S3 web service offers secure Internet file access at modest prices. Additionally, .NET 2.0's FtpWebRequest class offers access by programs to FTP sites. In this article, I show how to use S3 and FtpWebRequest to securely synchronize files on multiple machines.

To illustrate, I use Visual Studio 2005 to develop a sample application named "Synchronize Files" (available at http://www.ddj.com/code/). You can build it with Visual Studio 2005 or Visual C# 2005 Express Edition (http://msdn.microsoft.com/vstudio/express/visualcsharp). This program encrypts files for security, and compresses them to conserve bandwidth and storage space. It takes advantage of the Microsoft Enterprise Library for cryptography, logging, and exception management.

Building and Running The Sample App

The sample app uses the Cryptography, Exception Handling, and Logging "Application Blocks" from the January 2006 Microsoft Enterprise Library for .NET Framework 2.0. Before building the app, download the Enterprise Library (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/entlib2.asp) and run the install. After installing the library, specify an encryption key to encrypt/decrypt your files. To specify your key, first ensure the sample app's app.config file is writable. Run the Enterprise Library Configuration program. Select File/Open Application and open the sample app's app.config file. Right-click the Symmetric Provider on the left and select Remove. Then right-click Symmetric Providers and select New/Symmetric Algorithm Provider. Select RijndaelManaged and press OK. Make sure the Create a New Key radio button is selected, then click Next. Click the Generate button, then Next. Specify the key file path and press Next. Specify the data-protection mode and press Finish. On the right, change the Name from "RijndaelManaged" to "Symmetric Provider," which is the name the sample app expects. Finally, select File/Save Application.

Now it's time to build the app. Open SynchronizeFiles.sln in Visual Studio 2005, build the app, and run it. Select Options/Settings and select the S3 or FTP radio button to specify where your files will be stored. If you're using S3, enter the Access Key ID and Secret Access Key you received when signing up. Then press Get Canonical User ID and your Canonical User ID and Display Name is filled in. For an FTP site, first use an FTP program to create a folder on the FTP site for your home directory. Then go back to Synchronize Files and enter the FTP site (ftp://upload.comcast.net, for instance), the home directory you created, and your User ID and Password.

After entering your configuration information, press OK. Click the New button to create a bucket (folder) to hold your files. Then click Upload to upload your files. When files are selected by checking the checkbox in the DataGridView's leftmost column (Figure 1), they can be downloaded or deleted. When you press the Synchronize button, all files with a check in the Synchronize column are uploaded to the server if they've changed on the local machine.

[Click image to view at full size]

Figure 1: Synchronize files.

1 Synchronize Now! | 2 Amazon S3 | 3 FtpWebRequest | 4 The DataTransfer Abstract Class | 5 Log Messages Next Page
TOP 5 ARTICLES
No Top Articles.
DR. DOBB'S CAREER CENTER
Looking for a new job? open | close
Search jobs on Dr. Dobb's TechCareers
Function:

Keyword(s):

State:  
  • Post Your Resume
  • Employers Area
  • News & Features
  • Blogs & Forums
  • Career Resources

    Browse By:
    Location | Employer | City
  • Most Recent Posts:



    MICROSITES
    FEATURED TOPIC

    ADDITIONAL TOPICS

    INFO-LINK



     




    Techweb
    Informationweek Business Technology Network
    InformationweekInformationweek 500Informationweek 500 ConferenceInformationweek AnalyticsInformationweek Events
    Informationweek MagazineGlobal CIOIWK Government ITbMightyByte and SwitchDark Reading
    Digital LibraryIntelligent EnterpriseInternet EvolutionNetwork ComputingPlug Into The CloudDr. DobbsContentinople
    space
    TechWeb Events Network
    InteropVoiceConWeb 2.0 ExpoWeb 2.0 SummitEnterprise 2.0Mobile Business ExpoNoJitter
    Black HatGTECEnergy CampCloud ConnectGov 2.0 ExpoGov 2.0 Summit
    space
    Light Reading Communications Network
    Light ReadingLight Reading AsiaUnstrungCable Digital NewsInternet EvolutionPyramid Research
    Heavy ReadingLight Reading LiveLight Reading InsiderEthrnet ExpoTelco TVTower Technology Summit
    space
    Financial Technology Network
    Advanced TradingBank Systems and TechnologyInsurance and TechnologyWall Street and TechnologyAccelerating WallstreetBST SummitBuyside Trading SummitIT Summit
    space
    Microsoft Technology Network
    MSDNTechNetTotal IT ProTotal Dev ProNET Total Dev Pro CommunitySQL Total Dev Pro Community
    space