D
ok ich habe eine lösung gefunden :
static WebClient^ instFile = gcnew WebClient();
void download(){
if ( File::Exists("google.html"))
{
File::Delete( "google.html" );
}
DeleteUrlCacheEntry(TEXT("www.google.de"));
Uri^ file = gcnew Uri("www.google.de");
instFile->DownloadFileCompleted += gcnew AsyncCompletedEventHandler(this, &updates::DownloadFile );
instFile->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler(this, &updates::ProgressFile );
instFile->DownloadFileAsync(file,getDirS(L"Mepla_ISO_setup.msi"));
}
Dann außerhalb der funktion oben
/**** Tritt ein, wenn der asyncrone download abgeschlossen ist ! ****/
private: System::Void DownloadFile(Object^ sender,
AsyncCompletedEventArgs^ e)
{
dwnLoadButton->Text = "Download completed!";
dwnLoadButton->Enabled = false;
instButton->Enabled = true;
}
// Tritt während des Downloads ein //
private: System::Void ProgressFile(Object^ sender,
DownloadProgressChangedEventArgs^ e)
{
FileInfo^ file = gcnew FileInfo(getDirS(L"google.html"));
progressBar1->Value = e->ProgressPercentage;
dwnProgressBytes->Text = String::Format("{0:0.00} MB loaded !",file->Length/1000000.);
}
dwnLoadButton ist der button auf den geklickt wird, um den download zu starten und progressBar1 gibt die aktuelle fortschrittsanzeige in prozent an !