I saw a program to speed up the file copying process but I wanted to add some features to it, like, skip overwriting existing files, or no copying of existing files. Also, I wanted to control and monitor the copy process by a better method.
I think you have to know how to manage a thread, and must be familiar with memory buffers. That's all
Using the code
This code abstractly copies files from one path to another path, by read portions (equal to the buffer size) then writing it on the destination file, then looping the same for all files on the source directory. It displays progress information for a file, for the current directory, and for the entire copy process.
public string File_Copy(string strSource,
string strDestination,FileMode mode,
int bufferSize,int Action)
Readbytes = new byte[bufferSize];
FileStream Sfs = File.OpenRead(strSource);
Dfs = File.Open(strDestination,mode);
FileInfo Sinfo = new FileInfo(Sfs.Name);
FileInfo Dinfo=new FileInfo(Dfs.Name);
Form1.progCurrentFile.Text = strSource;
while (Sfs.Length - Sfs.Position>=bufferSize)
bufferSize = Settings.bufferSize;
Readbytes = null;
Readbytes = new byte[Settings.bufferSize];
if (Sfs.Position < Sfs.Length)
Points of Interest
- Copy files/directories from source directory to distention directory.
- Control memory buffer to speed up the copy process.
- Scan source directory to see all the files and directories inside, and get abstract info about the source directory.
- Pause / resume / cancel the copy process.
- Progress bars for a file, directory, and the copy process.
- In case of a damaged file found, it doesn't skip the copy process as Windows does. But it tells the user about it and the user can choose from one of the following options: write whatever can be written from the source file to the destination file /skip this file /skip all damaged files /write whatever can be written for all damaged files found.
Using the executable
- Click on the Source button to select the source directory.
- Click on the Destination button to select where you want to copy it to.
Now you can click Copy to start copying files. You may click on Progress to see how fast the files are copied and the actual percentage of completion. You may change the buffer size to speed up / slow down the copy process. You can also pause /resume /cancel the copy process at any time.
- Get information of a directory
You can use this application to get information about a particular directory, like, how many files are inside a directory, the names of files, size information, etc.
- Select a source directory.
- Click on the Info button.
- You may also select the Info tab to see an information display about the source directory.