void __fastcall Copy_Directory(AnsiString src_path, AnsiString dest_path)
{
if (MessageDlg("Копировать " + src_path + "\na\n" + dest_path + "?",
mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0) == mrNo)
return;
Application->MainForm->Cursor = crHourGlass;
if (DirectoryExists(src_path) && DirectoryExists(dest_path))
{
TSearchRec sr;
int iAttributes = 0;
iAttributes =
iAttributes|faReadOnly|faHidden|faSysFile|faVolumeID|faArchive;
if (FindFirst(src_path + "*.*", iAttributes, sr) == 0)
{
do
{
try
{
TFileStream *src = new TFileStream(src_path + sr.Name,
fmOpenRead),
*dst = new TFileStream(dest_path + sr.Name,
fmCreate);
src->Position = 0;
dst->Position = 0;
dst->CopyFrom(src, src->Size);
delete src;
delete dst;
} catch (...)
{
}
} while (FindNext(sr) == 0);
FindClose(sr);
}
}
Application->MainForm->Cursor = crDefault;
}
void __fastcall Copy_File(AnsiString file_name, AnsiString src_path,
AnsiString dest_path)
{
if (FileExists(src_path + file_name) && DirectoryExists(dest_path))
{
TFileStream *src = new TFileStream(src_path + file_name, fmOpenRead),
*dst = new TFileStream(dest_path + file_name, fmCreate);
src->Position = 0;
dst->Position = 0;
dst->CopyFrom(src, src->Size);
delete src;
delete dst;
}
}
Сергей Дворянцев
Предыдущий вопрос
|
|
Следующий вопрос
источник
by jenyok
|