Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.04.22;
Скачать: [xml.tar.bz2];

Вниз

Backup файла.   Найти похожие ветки 

 
inko   (2002-04-09 17:55) [0]

Как создать резервную копию (Backup) файла, в том же каталоге, где и оригинал?


 
AFROLOV   (2002-04-09 17:59) [1]

Скопировать его в этот каталог под другим именем.
Пример из Help по Delphi
The following example uses a button, a string grid, and a Save dialog box on a form. When the button is clicked, the user is prompted for a filename. When the user clicks OK, the contents of the string grid are written to the specified file. Additional information is also written to the file so that it can be read easily with the FileRead function.

procedure TForm1.Button1Click(Sender: TObject);
var
BackupName: string;
FileHandle: Integer;
StringLen: Integer;
X: Integer;
Y: Integer;
begin
if SaveDialog1.Execute then
begin
if FileExists(SaveDialog1.FileName) then
begin
BackupName := ExtractFileName(SaveDialog1.FileName);
BackupName := ChangeFileExt(BackupName, ".BAK");
if not RenameFile(SaveDialog1.FileName, BackupName) then

raise Exception.Create("Unable to create backup file.");
end;
FileHandle := FileCreate(SaveDialog1.FileName);
{ Write out the number of rows and columns in the grid. }
FileWrite(FileHandle,
StringGrid1.ColCount, SizeOf(StringGrid1.ColCount));
FileWrite(FileHandle,
StringGrid1.RowCount, SizeOf(StringGrid1.RowCount));
for X := 0 to StringGrid1.ColCount – 1 do
begin

for Y := 0 to StringGrid1.RowCount – 1 do
begin
{ Write out the length of each string, followed by the string itself. }
StringLen := Length(StringGrid1.Cells[X,Y]);
FileWrite(FileHandle, StringLen, SizeOf(StringLen));
FileWrite(FileHandle,
StringGrid1.Cells[X,Y], Length(StringGrid1.Cells[X,Y]);
end;
end;
FileClose(FileHandle);
end;

end;



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.04.22;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.007 c
1-69916
Val
2002-04-09 17:24
2002.04.22
inherited;


3-69675
IronHawk
2002-03-28 13:34
2002.04.22
Приветствую Мастеров ! Всевозможные операции в базе !


14-69974
lipskiy
2002-03-13 04:10
2002.04.22
И когда это вы все всё успеваете?


14-70030
antibiotik
2002-03-18 12:04
2002.04.22
Сеть


3-69716
Viktor Erko
2002-03-30 10:27
2002.04.22
Потеря 1-4 коп. при суммировании чисел из базы даных





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский