Click here to Skip to main content
13,344,508 members (45,191 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


27 bookmarked
Posted 24 Aug 2008

File Manager using C# and Multithreading

, 24 Aug 2008
Rate this:
Please Sign up or sign in to vote.
It helps to maintains files in directories with dynamically generated names using company's naming convention, versions and release




This is a tool to manage your files related to uploads on the server. When any one uploads updated files on server, generally he/she gets the backup of old files from server and and also creates a copy of new updated files in any directory. He/she gives the name to these directories according to company's naming convention, corresponding version and release. This tool gives an easy way to automate this process. In this application; there is a settings section where user can set the naming convention, prefix for backup folders and prefix for folders which contains the copy of new uploaded files. After making these settings, the user can use these settings multiple times and the user can also change settings in the future. This application also allows user to drag and drop the files for fast working and all the saved directories are binded in a treeview using a separate thread, so it also supports multiprocessing upto some level. This application uses a Microsoft access file to maintain the track of version and release and uses quick sort to decide on the new version or release.

Using the Code

Just download and run the application. You can also make its setup. This application contains the following sections:

  • Form1 (which is the default form)
  • Settings (which is opened as a dialog box when user clicks on settings button on Form1)
  • MyMessage (this form is used to display messages)

In this application, I have given a way to set company's naming convention with few fields it can be added as per company's requirement using some modification in source code.

The following function is called from a separate thread to start to bind treeview:

private void Get_nodes()
            string strPath = glbStrPath;
            strFiles = Directory.GetDirectories(strPath);
            Guid strguid;
            string strKey;
            string[] strName;
            char ch = Convert.ToChar("\\");
            //foreach (string strFile in strFiles)
            // int.TryParse(,intIndex);
                strName = strPath.Split(ch);
                strguid = System.Guid.NewGuid();
                strKey = strName[strName.GetUpperBound(0)] + Convert.ToString(strguid);
                if (InvokeRequired)
                    BeginInvoke(new Onadd_Field(add_Field), new object[] 
			{ strKey, strName[strName.GetUpperBound(0)] });
                if (HasSubDirectory(strPath))
                    Get_nodes(strPath, treeFileExplorer.Nodes[strKey]);
                BeginInvoke(new ThreadFinishedEvent(ThreadFinished));

        delegate void ThreadFinishedEvent();
        void ThreadFinished()
            progressBar1.Visible = false;
            lblSearch.Visible = false;
            pnlProcess.Visible = false;

            progressBar1.Value = progressBar1.Minimum;

The following function is a recursive function which is initially called from called from Get_nodes() function:

private void Get_nodes(string strPath, System.Windows.Forms.TreeNode CurrentNode)
            strFiles = Directory.GetDirectories(strPath);
            Guid strguid;
            string strNodeKey;
            string[] strName;
            string[] childs;
            char ch = Convert.ToChar("\\");
            foreach (string strFile in strFiles)
                // int.TryParse(,intIndex);
                    childs = Directory.GetDirectories(strPath + "\\");
                    strName = strFile.Split(ch);
                    strguid = System.Guid.NewGuid();
                    strNodeKey = strName[strName.GetUpperBound(0)] + 
                    if (InvokeRequired)
                        BeginInvoke(new Onadd_Node(add_Node), new object[] 
		      { CurrentNode, strNodeKey, strName[strName.GetUpperBound(0)] });

                    if (HasSubDirectory(strFile))
                        Get_nodes(strFile, CurrentNode.Nodes[strNodeKey]);

The following functions are called from the above functions to add nodes in treeview:

private delegate void Onadd_Field(string key, string item);

        private void add_Field(string key, string item)
            treeFileExplorer.Nodes.Add(key, item);

        private delegate void Onadd_Node(System.Windows.Forms.TreeNode CurrentNode, 
		string key, string item);
        private void add_Node(System.Windows.Forms.TreeNode CurrentNode, 
		string key, string item)
            CurrentNode.Nodes.Add(key, item);

Points of Interest

When I was developing this application, I experienced that if we wish to use any windows form control in a separate thread, we have to use "Invoke" or "BeginInvoke" function. To call functions within "Invoke" or "BeginInvoke", we need to make delegate for the function which uses windows form control.


This is the first version of this application. Please give me feedback to make its next releases and versions. This is completely free and if any one goes through any other file manager of the same type, obviously those are paid.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Er. Virendra
Software Developer (Senior) Photon Infotech
India India
I passed my B.Tech. in 2007 from SRMCEM, Lucknow and currently I am working as a software developer in .Net technology.

You may also be interested in...

Comments and Discussions

GeneralIssue has been fixed! Pin
Er. Virendra26-Aug-08 1:10
memberEr. Virendra26-Aug-08 1:10 
GeneralNice application, but unable to understand Pin
adithyadugyala25-Aug-08 22:15
memberadithyadugyala25-Aug-08 22:15 
GeneralRe: Nice application, but unable to understand Pin
Er. Virendra26-Aug-08 1:59
memberEr. Virendra26-Aug-08 1:59 
GeneralNot Able to run this application Pin
raju87825-Aug-08 19:16
memberraju87825-Aug-08 19:16 
GeneralRe: Not Able to run this application Pin
Er. Virendra26-Aug-08 2:00
memberEr. Virendra26-Aug-08 2:00 

I uploaded the fixed release of the application and you can use it in following way:

1. Click settings, fill all the fields and click "Submit". Application will be restarted with new settings. {"Path" field indicates the directory in which you want to save your folders, it is not needed to update with every use of application}.
2. There are two modes in the fields as shown in the right top menu items "Fresh List" and "Update List". Default is "Fresh List", it creates a new version and "Update List" creates new release of clicked folder name from treeview (because when user goes in update mode treeview binds all the created directories and saved folders are the node for this treeview).
3. Just drag and drop files (not folders because folder is automatically generated with new version or release) or you can choose "File -> Open".
4. Fill all the fields and click "Move" or "Copy" (Operation is same as the name).

This is the general way to use this application. If you have any question please let me know.

[Note: I developed it when i got some free time from my daily work, so refinement is needed therefore I need feedbacks and bugs. so, thanks for your valuable feedback]

Thanks and regards,


GeneralNice work, but can't compile... Pin
thompsons25-Aug-08 7:01
memberthompsons25-Aug-08 7:01 
GeneralRe: Nice work, but can't compile... Pin
adithyadugyala25-Aug-08 22:32
memberadithyadugyala25-Aug-08 22:32 
GeneralRe: Nice work, but can't compile... Pin
Er. Virendra26-Aug-08 2:01
memberEr. Virendra26-Aug-08 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 25 Aug 2008
Article Copyright 2008 by Er. Virendra
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid