如题,最好有相应的代码。对于这一块确实不熟
解决方案 »
- delphi下的时钟和线程区别有多大?
- 请问一个判断stringgrid为空怎么写啊
- 服务如何自动启动?
- 得到本周日期的起始
- 躺床上一个半小时,愣是没睡不着!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- [问题]在一个窗体里有15个edit控件,要同时改变它们的Enable属性。怎样做最简单? 谢谢。
- 江湖朋友﹐高分求救﹗
- 系统音量控制(如何获取当前音量值?)
- 请教几个问题?(关于table,findkey,try...except)
- 这么复杂的触发器,可以做出来吗?
- windows 关机效果 那样的最上层的模式窗口
- select count(*) from问题
Up
这个办法很好
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, 'srcfile.tst');
AssignFile(DestFile, 'destfile.tst');
// 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);
{ 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;
试试这个,看是不是完全是字符组成.
var
arrResult: array of Char;
begin
//... get Stream data to s(TStream or TMemoryStream, TFileStream....) s.Position := 0;
SetLength(arrResult, s.Size); s.Write(arrResult, s.Size)
ShowMessage(arrResult);
end;