파일 관리 클래스 함수 (1)

4163 단어 문건

//         FileExists
var
  f: string;
begin
  f := 'c:\temp\test.txt';
  if not FileExists(f) then
  begin
    //       
  end;
end;

 
// DirectoryExists var dir: string; begin dir := 'c:\temp'; if not DirectoryExists(dir) then begin // end; end;
// DeleteFile; Windows.DeleteFile var f: string; begin f := 'c:\temp\test.txt'; //DeleteFile(f); // Boolean // API: Windows.DeleteFile(PChar(f)); // Boolean end;
// RemoveDir; RemoveDirectory var dir: string; begin dir := 'c:\temp'; RemoveDir(dir); // Boolean // API: RemoveDirectory(PChar(dir)); // Boolean end;
// GetCurrentDir var dir: string; begin dir := GetCurrentDir; ShowMessage(dir); //C:\Documents and Settings\wy\My Documents\RAD Studio\Projects end;
// SetCurrentDir; ChDir; SetCurrentDirectory var dir: string; begin dir := 'c:\temp'; if SetCurrentDir(dir) then ShowMessage(GetCurrentDir); //c:\temp // ChDir(dir); // // API: SetCurrentDirectory(PChar(Dir)); // Boolean end;
// GetDir var dir: string; b: Byte; begin b := 0; GetDir(b,dir); ShowMessage(dir); // // : 1、2、3、4... : A、B、C、D... //0 end;
// RenameFile var OldName,NewName: string; begin OldName := 'c:\temp\Old.txt'; NewName := 'c:\temp\New.txt'; if RenameFile(OldName,NewName) then ShowMessage(' !'); // : SetCurrentDir('c:\temp'); OldName := 'Old.txt'; NewName := 'New.txt'; if RenameFile(OldName,NewName) then ShowMessage(' !'); end;
// CreateDir; CreateDirectory; ForceDirectories var dir: string; begin dir := 'c:\temp\delphi'; if not DirectoryExists(dir) then CreateDir(dir); // Boolean // API: CreateDirectory(PChar(dir),nil); // Boolean // : dir := 'c:\temp\CodeGear\Delphi\2007\ '; ForceDirectories(dir); // Boolean end;
// RemoveDir; RemoveDirectory var dir: string; begin dir := 'c:\temp\delphi'; RemoveDir(dir); // Boolean // API: RemoveDirectory(PChar(dir)); // Boolean end;
// FileCreate var FileName: string; i: Integer; begin FileName := 'c:\temp\test.dat'; i := FileCreate(FileName); if i>0 then ShowMessage(' : ' + IntToStr(i)) else ShowMessage(' !'); end;
// GetFileVersion var s: string; i: Integer; begin s := 'C:\WINDOWS
otepad.exe'; i := GetFileVersion(s); // -1 ShowMessage(IntToStr(i)); //327681 ( ) end;
// DiskSize; DiskFree var r: Real; s: string; begin r := DiskSize(3); // C: , r := r/1024/1024/1024; Str(r:0:2,s); // s := 'C : ' + s + ' GB'; ShowMessage(s); //xx.xx GB r := DiskFree(3); // C: r := r/1024/1024/1024; Str(r:0:2,s); s := 'C : ' + s + ' GB'; ShowMessage(s); //xx.xx GB end; // - (2)

좋은 웹페이지 즐겨찾기