知道一个文件的中HEAD的长度,如何去掉?比如head长(000H---aobH),如何去掉000H到
A0BH之间的内容,另存为一个文件?
A0BH之间的内容,另存为一个文件?
解决方案 »
- type mismatch for field'备注',expecting:String actual:Memo错误
- 如何用Delphi,在 Excel 表中的记录根据多个值确定某一行的行号?
- 字符串Adotable1DESC.VALUE内的值,如果字段内的值有',例如,FRIAN'S ENRCY ,就无法插入ms-sqlserver内的表,请问如何修改??
- 线程的简单问题,知道的快来拿分!!!
- 请问哪里有Delphi4下载?
- 100大分相送,在线等待--求读取内存流问题。
- 请教sql里'select 。。。
- 一个sql语句问题,请指教~!
- 大家有认识水平很高的mm程序员吗?
- RichEdit的EN_VSCROLL和EN_HSCROLL
- 如何处理这样的文本文件?
- 我是一名新手,请问如何知道控件的方法及其用途
你不该说那样的话。需知尺有所短,寸有所长。术业有专攻,个人针对的面也不一样,浩瀚未知,谁能穷尽?譬如我刚刚由一星变成二星,可我明白自己就只懂一丁点,象是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的长度