需先安裝 JEDI VCL for Delphi
uses
JclFileUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
TempFileStream: TJclTempFileStream;
TempPath: string;
begin
// 建立暫存檔
TempFileStream := TJclTempFileStream.Create('~');
try
Memo1.Lines.Add(TempFileStream.FileName);
TempFileStream.Write('12345', 5);
TempFileStream.Seek(0, soBeginning);
Memo1.Lines.LoadFromStream(TempFileStream);
finally
TempFileStream.Free;
end;
TempPath := PathGetTempPath;
Memo1.Lines.Add(TempPath);
// 刪除檔案到資源回收筒
FileDelete( TempPath + '\~*.tmp', True);
// 刪除目錄到資源回收筒
DeleteDirectory(TempPath + '\dir', True);
end;
沒有留言:
張貼留言