檔案(夾)操作

2022-05-14 21:42:48 字數 1795 閱讀 4071

對檔案和資料夾操作的類

1.fileinfo具體檔案,使用此類的物件,可以獲得問價大小等各種資訊 繼承自filesysteminfo

建立物件,fileinfo fi= new fileinfo();

常用屬性

·         name 檔名稱

·         extension 副檔名

·         fullname 檔案完全路徑(物理路徑)

·         length 檔案大小,單位為位元組

·         creationtime 檔案建立時間

·         lastaccestime 檔案上次訪問時間

·         lastwritetime 檔案上次修改時間

·         directoryname 所在的資料夾

·         attributes 檔案屬性,如唯讀,隱藏等

2.file提供static方法,檔案新建、複製、移動和刪除

·         create(filepath)

·         copy(filepath1,filepath2)

·         move(filepath1,filepate2)

·         delete(filepath)

·         exists(filepath)

·         createtext(filepath)

3.directoryinfo具體資料夾,使用此類的物件可以獲得資料夾大小等各種資訊 繼承自filesysteminfo

建立物件 directoryinfo di = new directoryinfo ();

常用屬性

·         name 資料夾名稱

·         fullname 資料夾完全路徑(物理路徑)

·         creationtime 資料夾建立時間

·         lastaccesstime 資料夾上次訪問時間

·         lastwritetime 資料夾上次修改時間

·         parent 父資料夾

·         root 所在根目錄

4.directory提供static方法,資料夾的新建、移動和刪除

·         createdirectory(dirpath)

·         move(dirpth1,dirpath2)

·         delete(dirpath)

·         exists(dirpath)

·         getdirectories(dirpath) 獲取子資料夾

·         getfiles(dirpath) 獲取子檔案

5.path檔案路徑,提供路徑處理

·         combine

·         getdirectoryname

·         getextension

·         getfilename

·         getfilenamewithoutextension

·         getfullpath

·         getpathroot

·         gettempfilename

·         gettemppath

資料夾操作

建立資料夾 char buf 256 getcurrentdirectory 256,buf 獲取程式根目錄路徑 m name.getwindowtext name strcat buf,strcat buf,name createdirectory buf,null 刪除資料夾 char buf ...

拷貝檔案 資料夾 建立資料夾 刪除資料夾操作

qt拷貝檔案 資料夾 建立資料夾 刪除資料夾操作 cpp view plain copy brief 拷貝檔案到目的資料夾 param srcfilename 原始檔全路徑,比如 f tx wwxx.txt f tx des desd param desfilepathname 要copy到的目的路...

Delphi 資料夾操作

uses shellapi 建立資料夾 procedure tfrmmain.cxbutton1click sender tobject begin createdirectory pchar extractfilepath paramstr 0 microblue nil end 刪除資料夾,放到...