知道一个文件的中HEAD的长度,如何去掉?比如head长(000H---aobH),如何去掉000H到
A0BH之间的内容,另存为一个文件?
A0BH之间的内容,另存为一个文件?
解决方案 »
- DBNavigator按扭enable调用
- 语句 button.ImageIndex := 3; 图标不能动态绑定到控件上?
- 从一个数组中怎么取一个记录出来.
- 斗胆提问:D版市场上有光盘安装版的D7吗?
- 还是有关TQuery, TSession和TDatabase
- intraWeb 生成的文件*.So文件运行在什么服务器上 怎么设置才能运行?acaphe 2 dso application
- 终于到周末了,散分!顺便测测大家的智商...
- 如何在RICHEDIT里改变某行字的颜色?或是有什么其他控件可以完成的?
- 请问如何在过滤时实现部分匹配.
- 谁知道速达3000服装版中有关货品资料中"颜色"和"尺寸"的二维表在DELPHI下如何具体实现
- 如何处理这样的文本文件?
- 我是一名新手,请问如何知道控件的方法及其用途
你不该说那样的话。需知尺有所短,寸有所长。术业有专攻,个人针对的面也不一样,浩瀚未知,谁能穷尽?譬如我刚刚由一星变成二星,可我明白自己就只懂一丁点,象是TCP/IP协议及网络编程等等许许多多的东西至今都未涉及,一窍不通,对文件操作也只是刚刚做程序积累了一点点经验。愿我们都能善待他人,共同提高。共勉。
var
SrcFile, DestFile: File;
BytesRead, BytesWritten, TotalRead: Integer;
Buffer: array[1..500] of byte;
FSize: Integer;
begin
{ Assign both the source and destination files to their
respective file variables }
AssignFile(SrcFile, 'C:\graphinfo\tmp\edit.dwg');
AssignFile(DestFile, 'C:\graphinfo\tmp\edit0.dwg');
// Open the source file for read access.
Reset(SrcFile, 1);
try
// Open destination file for write access.
Rewrite(DestFile, 1);
try
{ Encapsulate this into a try..except so that we can erase the file if
an error occurs. }
try
// Initialize total bytes read to zero.
TotalRead := 0;
// Obtain the filesize of the source file
//FSize := FileSize(SrcFile)-2571;
FSize:=2571;
{ Read SizeOf(Buffer) bytes from the source file
and add these bytes to the destination file. Repeat this
process until all bytes have been read from the source
file. A progress bar is provided to show the progress of the
copy operation. }
repeat
BlockRead(SrcFile, Buffer, SizeOf(Buffer), BytesRead);
if BytesRead > 0 then
begin
BlockWrite(DestFile, Buffer, BytesRead, BytesWritten);
if BytesRead <> BytesWritten then
raise Exception.Create('Error copying file')
else begin
TotalRead := TotalRead + BytesRead;
prbCopy.Position :=Trunc(TotalRead / Fsize) * 100;
prbCopy.Update;
end;
end
until BytesRead = 0;
except
{ On an exception, erase the destination file as it may be
corrupt. Then re-raise the exception. }
Erase(DestFile);
raise;
end;
finally
CloseFile(DestFile); // Close the destination file.
end;
finally
CloseFile(SrcFile); // Close the source file.
end;
end;
Buffer2: array of byte;......
SetLength(Buffer2,FSize); //设置Buffer2的长度BlockRead(SrcFile, Buffer1, SizeOf(Buffer1),BytesRead); // 读取头2571个保留字节BlockRead(SrcFile, Buffer2, SizeOf(Buffer2),BytesRead); //再读取余下的所有字节数据:
......最后再用BlockWrite把Buffer2的内容写入一个新文件中即可。
改为:
SetLength(Buffer2,FileSize(SrcFile)-2571); //设置Buffer2的长度