×
How I Organise My Downloads Folder With .Net Core (C# Automation)

Recently, I felt overly annoyed by my messy download folder on my personal computer. There were too many files, and it was in a total mess. I thought to write a simple bot to address this problem.

The Solution

Solution is a Bot that loops the download,desktop or any other folder and determines the file type for each and every file. Subsequently, it creates a folder for that file type. All files with the same file type will be transferred to this folder and or Organise by Date.

We use .Net Core to make it cross platform. but same code work well for .Net Framework ,.Net Standard and on Xamarin so it work on every popular device today.

Start

let start it by creation new project and initialize git.

dotnet new console -o “FileOrganizer”
git init
git add *.*

Working

.Net provide FileSystemWatcher to watch for changes in a specified directory. You can watch for changes in files and sub directories of the specified directory. You can create a component to watch files on a local computer, a network drive, or a remote computer.

The FileSystemWatcher does not raise events for CDs and DVDs, because time stamps and properties cannot change. Remote computers must have one of the required platforms installed for the component to function properly.

Move File

we make directory in Organised path such as File Type , year , Mount and then date.

Error One

it work fine but when it overwrite file with same name, so we add check.

Error Two

when file is other press it throw exception to overcome this problem we try to reach file until file is open to move.

Addition

so we have to add configuration file to add or update information with out making changes in code and generate logs of files with time.

Config File

YouTube Video

Project

×

Hey!

This is not just another subscription Stay updated on the latest tech trends and insights with GrowBit Tech weekly newsletter.