如何创建文本文件
解决方案 »
- 求报表控件 FastReports 4.10.5 以上的 版本
- 如何将多个exe程序合并到一个exe程序里边,并且运行后能释放到不同的目录的!
- 如何在delphi中实现矩阵的逆运算,转置,以及矩阵的乘法和加法.万分感激!!!
- 怎样才能使CoolBar只显示一行
- 请问各位高手如何在多媒体软件中实现左右声道的控制?
- 怎么才能用RBuilder实现报表的小计累计功能
- [error]Left sidecannot be assigned to
- 这样的图象手工分割
- 想把ComboBox组件里的(性别)选项保存到数据库中,为何下面的程序不对呢?
- 祖先类中有一个声明在private中的procedure,现在想在孩子类中修改这个procedure,怎么办?
- dbgrid简单问题,早答早结贴
- 如何利用回滚技术,保证提交给两个数据库的数据一致?(分不够再加!)
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;