I am using AES Crypt in my C# program and I want to show a progress bar so that user can know how much work is done. I want to encrypt one file at a time so no need to handle progress dialogs for multiple files or I want it simple in other words.
I have tried but I have no idea on how to do this? Please help me this is important.
In the accompanied AES c++ gui program the programmer have created a progress bar and I liked it very much. I opened that c++ code and tried to figure out how it works but even after debugging the code line by line, I still don't understand how it is done in c++.
Can anyone give me a sample code for this problem?
How to show progress bar while encrypting file in C#
-
- Posts: 1
- Joined: Mon Sep 10, 2012 7:22 am
- paulej
- Posts: 593
- Joined: Sun Aug 23, 2009 7:32 pm
- Location: Research Triangle Park, NC, USA
- Contact:
Re: How to show progress bar while encrypting file in C#
What I did in the C++ code was pause periodically and send a message to the dialog box containing the status bar. You'll see this code in the AESCryptWorkerThreads.cpp file:
What this does is check if any of these conditions are true:
I hope that helps with working out an approach in C#
Code: Select all
if ((clock() - last_clock_time >
(CLOCKS_PER_SEC / 4)) ||
(bytes_left == 0) ||
(current_percent > last_percent))
{
// Update the progress bar
dlg.SendDlgItemMessage(
IDC_PROGRESSBAR,
PBM_SETPOS,
(WPARAM) current_percent,
0);
dlg.UpdateWindow();
DoMessageLoop();
if (dlg.abort_processing == true)
{
error_abort = true;
break;
}
last_clock_time = clock();
last_percent = current_percent;
}
- 250ms has passed since the last update
- One or more percentage of the file has been decrypted
- There are no bytes left to process (at 100%; probably redundant)
I hope that helps with working out an approach in C#