File Archiver

Service for archiving files to a central location. Download the service. (Zip file containing the MSI installer for the service). It does not have to run as a service. You can run it standalone as an application if you call it with a -run argument. For example FileArchiver -run will run the application one time, and not as a service.

The service or application is just a wrapper around the wcf library that you will get with the service. You can have any client (WCF Service or plain application) around that library. Information about the library will be available upon request.

FileArchiver was developed mainly to archive log files from various applications into one centralized location. The Service is multi-threaded, and can be configured in many ways. It can monitor multiple source directories based on wild card search or regular expressions. You can also filter based on text (regular expression search) within the file itself. Other features are that you can compress the destination folders created (SharpZipLib is used for zipping the folders).

FileArchiver was developed under the GNU General Public License. The source code is attached here. If you decide to enhance it, please post back the code to me, so that the community can gain from the enhancements.

System Requirements:
   * .NET Framework 3.5 SP 1.
   *  Runs on Windows.

Configuration Settings for the source folder:
   * sourceFolder: Source Folder for the Archive.
   * wildCardExpression: Wild Card Expression used to search the file (*.txt)
   * regularExpression: Use regular expression instead of the wild card.
   * searchInFileRegex: Used to archive files based on text within the file.
   * includeSubFolders: Includes all the sub folders in the source.
   * archiveBeforeDays: Number of days before which you can archive. Defaults to 0 (which is prior to today)

Configuration Settings for destination folder:
   * overwriteFiles: A flag determining whether to overwrite destination files if a file with the same name exists.
   *  zipOutput: Compress output folders.
   * destinationStyle: Can be ByLastModifiedDate, ByLastModifiedMonth, ByLastModifiedYear, ByCreatedDate, ByCreatedMonth, ByCreatedYear

Configuration Settings for the Service:
   * ServiceTimerInterval: Determines how often the service will scan the source folders. (Milli Seconds)
   * MaxThreadCount: Maximum number of threads that we can have running at any point during the service run.

Sample Configuration (you can set up multiple archive items):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <section name="ArchiveConfig"
        type="FileArchiverLib.ArchiveConfig, FileArchiverLib" />
   </configSections>
 
   <appSettings>
      <add key="ServiceTimerInterval" value="10000"/>
      <add key="MaxThreadCount" value="10"/>
   </appSettings>

   <ArchiveConfig>
      <ArchiveConfigItems>
         <clear />
         <add
            name="Archive1"
            archiveBeforeDays="1"
            sourceFolder="C:\Temp\FileArchiverSource"
            regularExpression="txt$"
            wildCardExpression="*.txt"
            searchInFileRegex="23*4"
            includeSubFolders="false"
            destinationFolder="C:\Temp\FileArchiverDestination"
            overwriteFiles="true"
            zipOutput="true"
          />
      </ArchiveConfigItems>
   </ArchiveConfig>
</configuration>
Picture