comment je pourrais créer un timer de 10 secondes par exemples
merci
comment je pourrais créer un timer de 10 secondes par exemples
merci
En fait j'y ai pensé parce que j'ai un problème :
voila j'execute une méthode qui me decompress un fichier, le fichier et le resultat d'un decryptage
donc quand je decrypte puis je decompress (file1->file2), il me genere une exception comme quoi le fichier file 1 est utilisé par un autre process, pourtant je ferme le stream lors du decryptage.
pour etre sur j'excute en en utilisant le debug pas par pas et ca marche nikel ! mais quand je reviens au mode normal ca revient
mes des fois ca marche dans le mode normal donc je comprend pas ce que je dois faire?
montre voir un code minimal qui reproduit le problème
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 //Decryption private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { if(textBox1->Text=="") System::Windows::Forms::MessageBox::Show("source not filled!"); if(textBox2->Text=="") System::Windows::Forms::MessageBox::Show(" destination not filled!"); if(textBox3->Text=="") System::Windows::Forms::MessageBox::Show("password not filled!"); if((!(textBox1->Text==""))&&(!(textBox2->Text==""))&&(!(textBox3->Text==""))) { //the file to be decrypted val1 = textBox1->Text; //the destination val2 = textBox2->Text; //the password val4 = textBox3->Text; //val3 = val1->Replace("\\","\\\\") ; //val5 = val2->Replace("\\","\\\\") ; //open the file to be decrypted FileStream ^fs = gcnew FileStream(val1, FileMode::Open); BinaryReader ^br = gcnew BinaryReader(fs); //create the destination if (File::Exists(val2)) File::Delete(val2); FileStream ^fsw = gcnew FileStream(val2,FileMode::CreateNew); BinaryWriter ^bw = gcnew BinaryWriter(fsw); try { //decrypting the file bw->Write(Decrypter(br->ReadBytes((int)fs->Length),val4)); } catch (Exception^) { } finally { br->Close(); fs->Close(); bw->Close(); fsw->Close(); } textBox3->Clear(); Form3::Close(); } //decompression String ^ t1 = textBox1->Text; String ^ t2 = textBox2->Text; List<ListViewItem^>^ mylistof1 = gcnew List<ListViewItem^>(); String ^q =t2; // the user forgot to fill the directory placement if (t1=="") System::Windows::Forms::MessageBox::Show("please give a directory placement!" ); // the user forgot to fill the file destination if (t2=="") System::Windows::Forms::MessageBox::Show("please give a file destination!" ); // the user has filled the directory placement and the file destination if ((!(t1==""))&& (!(t2==""))) { listView3->Clear(); // decompressing the compressed file DecompressDir(t1, t2); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 ///fonction pour decompresser void DecompressDir(String ^dirSource, String ^ dirDestination) { // creating the destination directory DirectoryInfo^ di = Directory::CreateDirectory(dirDestination); // creating the temporory directory if (Directory::Exists("C:\\Temp\\eramahy")) { deletdir("C:\\Temp\\eramahy"); Directory::Delete("C:\\Temp\\eramahy"); } DirectoryInfo^ dim = Directory::CreateDirectory("C:\\Temp\\eramahy"); String ^path = dirSource; String ^pathnew = dirDestination; //Initializing the second list view listView3->View = View::Details; listView3->LabelEdit = true; listView3->AllowColumnReorder = true; listView3->CheckBoxes = true; listView3->FullRowSelect = true; listView3->GridLines = true ; listView3->Sorting = SortOrder::Ascending; /* if(File::Exists("C:\\Temp\\testt")) File::Delete("C:\\Temp\\testt"); File::Copy(dirSource,"C:\\Temp\\testt"); File::Delete(dirSource); File::Copy("C:\\Temp\\testt",dirSource); File::Delete("C:\\Temp\\testt");*/ //open the compressed file FileStream ^fs = gcnew FileStream(dirSource, FileMode::Open); BinaryReader ^br = gcnew BinaryReader(fs); //reading the original structure of the compressed data String^a = br->ReadString();
bon ... ton code est pas minimal du tout ...
ce que tu veux faire, c'est décrypter un fichier et enchainer sur une décompression, c'est bien ca ?
en fait il y a un boutton pour decrypter , donc apres le decryptage j'ai le resultat : "file decrypted"
et apres je veux decompresser le fichier "file decrypted" en fichier decompressé. l'exception se genere lorsque je clik sur decompress il me dit que le fichier "file decrypted" est utilisé par un autre process
pourtant j'ai vérifié le stream est bien fermé à la fin du decryptage ..
Partager