login about faq

Hi, can i ask one question please?

Its possible report progress for progress bar while making function CkEncryptFile?

this is H file

private: System::Void button_encryptFolder_ItemClick(System::Object^ sender, DevExpress::XtraBars::ItemClickEventArgs^ e) { folderBrowserDialog_encryptZipFolder->ShowDialog(); backgroundWorker_encryptFolder->RunWorkerAsync(); } private: System::Void barButtonItem_encryptZipFolder_ItemClick(System::Object^ sender, DevExpress::XtraBars::ItemClickEventArgs^ e) {

}
private: System::Void backgroundWorker_encryptFolder_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) {
    String^ dirPath = folderBrowserDialog_encryptZipFolder->SelectedPath;
    DirectoryInfo^ dirInfo = gcnew DirectoryInfo(dirPath);
    SearchTree(dirInfo);
}
private: System::Void backgroundWorker_encryptFolder_ProgressChanged(System::Object^  sender, System::ComponentModel::ProgressChangedEventArgs^  e) {
    Datapacket^ dp = dynamic_cast<Datapacket^>(e->UserState);
    bottomText1->Caption = dp->bottomText;
}

and this is function in C file

void ProgramPreSrandu::MyForm::SearchTree(DirectoryInfo ^ root) { System::Threading::Thread::Sleep(.5f); Datapacket^ dp = gcnew Datapacket();

Crypt2^ crypto = gcnew Crypt2();
bool success;
crypto->UnlockComponent("30-day trial");
crypto->CryptAlgorithm = "aes";
crypto->KeyLength = 256;
crypto->SetSecretKeyViaPassword("heslo");

array<DirectoryInfo^>^ subDirs = nullptr;
array<FileInfo^>^ files = nullptr;

try
{
    files = root->GetFiles("*.*");
}
catch (UnauthorizedAccessException^ e)
{
    //Console::WriteLine(e->Message);
}
catch (DirectoryNotFoundException^ e)
{
    //Console::WriteLine(e->Message);
}

if (files != nullptr)
{
    for each (FileInfo^ file in files)
    {
        dp->bottomText = String::Format("File: {0}", file->Name);
        backgroundWorker_encryptFolder->ReportProgress(0, dp);
        success = crypto->CkEncryptFile(file->FullName, String::Format("{0}\\encrypted-{1}", Path::GetDirectoryName(file->FullName), file->Name));
        /*if (!success)
        {
            MessageBox::Show(crypto->LastErrorText);
        }*/
    }
    subDirs = root->GetDirectories();

    for each (DirectoryInfo^ dirs in subDirs)
    {
        SearchTree(dirs);
    }
}

}

Thanks :)

asked Jun 07 at 04:10

BAILANDO's gravatar image

BAILANDO
32


link

answered Jun 07 at 06:07

muggle222's gravatar image

muggle222
183

really dont know how to use this in my code, canyou please make small example for me? many thanks :) soft is writen in C++

link

answered Jun 07 at 07:13

BAILANDO's gravatar image

BAILANDO
32

edited Jun 07 at 07:15

I have done this, how can i use it? i have this error: http://prntscr.com/bde7q5

public ref class MyCrypt2Progress : public CkCrypt2Progress { public: MyCrypt2Progress() { } virtual ~MyCrypt2Progress() { }

    void PercentDone(int pctDone, bool *abort)
    {
        Console::WriteLine(String::Format("Percent done: {0}\%", pctDone));
    }
    void ProgressInfo(const char *name, const char *value)
    {
        Console::WriteLine(String::Format("Progress info. Name: {0}, Value: {1}", marshal_as<String^>(std::string(name)), marshal_as<String^>(std::string(value))));
    }
};
link

answered Jun 07 at 07:28

BAILANDO's gravatar image

BAILANDO
32

edited Jun 07 at 07:30

i have done my own progress method via background workers, for now :)

link

answered Jun 07 at 09:06

BAILANDO's gravatar image

BAILANDO
32

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×22

Asked: Jun 07 at 04:10

Seen: 643 times

Last updated: Jun 07 at 09:06

powered by OSQA