A Windows Service built with C# and .NET Framework that monitors a source folder for newly added files. When a new file is detected, the service automatically renames it using a GUID and moves it to a destination folder while logging all operations.
- Monitor a source folder using
FileSystemWatcher. - Detect newly created files automatically.
- Rename files using a unique GUID while preserving the original extension.
- Move files to a destination folder.
- Log service events and file operations with timestamps.
- Read configuration values from
App.config. - Automatically create required directories if they do not exist.
- Retry file movement when files are temporarily locked.
- Support Console Debug Mode for easier development and testing.
- Windows Service Installer for deployment.
- C#
- .NET Framework
- Windows Service
- FileSystemWatcher
- App.config
- Event Viewer
- Windows Service Installer
Configure the application using App.config.
<appSettings>
<add key="Source" value="C:\FileMonitoring\Source"/>
<add key="Destination" value="C:\FileMonitoring\Destination"/>
<add key="Log" value="C:\FileMonitoring\Logs"/>
</appSettings>- The service monitors the source folder.
- When a new file is detected:
- A GUID filename is generated.
- The original file extension is preserved.
- The file is moved to the destination folder.
- Every operation is logged with a timestamp.
The service logs:
- Service start
- Service stop
- File detection
- File movement
- Errors during processing
The project supports Console Mode for debugging.
When running interactively, the service:
- Starts as a console application.
- Displays runtime information.
- Allows stopping the service with a key press.
The service can be installed using either:
- InstallUtil
- sc.exe
Example:
sc create FileMonitoringService binPath= "C:\Path\File Monitoring.exe" start= autoStart the service:
sc start FileMonitoringServiceRemove the service:
sc delete FileMonitoringServiceFile Monitoring
│
├── FileMonitoringService.cs
├── Installer1.cs
├── Program.cs
├── App.config
└── Properties
This project is for learning purposes.