www.pudn.com > Auto_Copy.rar > Acopy_File.cpp
//--------------------------------------------------------------------------- #include#pragma hdrstop #include "Acopy_File.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { try { String File_Name=""; String File_Name_Temp=""; String Des_Name=""; String Des_Path; BOOL Copy_Flage; Des_Path=Edit2->Text; FileListBox2->Color=RGB(255,255,255); FileListBox2->Directory=Des_Path; FileListBox2->Update(); FileListBox2->Refresh(); FileListBox1->Directory=Edit1->Text; String Dir_Path=FileListBox1->Directory; FileListBox1->Update(); FileListBox1->Refresh(); int Index_Count=FileListBox1->Items->Count; ProgressBar1->Min=0; ProgressBar1->Max=Index_Count-1; ProgressBar1->Smooth=true; for (int Loop_Count=0;Loop_Count ItemIndex=Loop_Count; File_Name=FileListBox1->Items->Strings[Loop_Count]; File_Name_Temp=Dir_Path+"\\"+File_Name; Des_Name=Des_Path+File_Name; Copy_Flage=CopyFile(File_Name_Temp.c_str() ,Des_Name.c_str() ,FALSE ); if(Copy_Flage==0) break; FileListBox2->Update(); FileListBox2->Refresh(); ProgressBar1->Position=Loop_Count; } FileListBox2->Update(); FileListBox2->Refresh(); if(Copy_Flage==0 || (FileListBox1->Items->Count!=FileListBox2->Items->Count)) FileListBox2->Color=RGB(255,0,0); else FileListBox2->Color=RGB(0,255,0); FileListBox2->Update(); FileListBox2->Refresh(); } catch(...) { MessageBox(Application->Handle,"Please check Path","Error",MB_OK); return; } } //--------------------------------------------------------------------------- void __fastcall TForm1::FormShow(TObject *Sender) { FileListBox2->Directory=Edit2->Text; FileListBox2->Update(); FileListBox2->Refresh(); FileListBox1->Directory=Edit1->Text; FileListBox1->Update(); FileListBox1->Refresh(); } //---------------------------------------------------------------------------