ios 取本地檔案大小,檔案相關屬性

2021-09-06 05:47:06 字數 668 閱讀 9788

**  

要做乙個本地檔案管理的小功能,獲取應用沙盒目錄及檔案列表的方法都比較常見,但是想獲取指定檔案大小時,網上卻很少提及,看了半天原始碼,才找到地方,在這裡share一下:

nsfilemanager *fm  = [nsfilemanager defaultmanager];

// 取檔案大小

nserror *error = nil;

nsdictionary* dictfile = [[fm attributesofitematpath:fullfile error:&error] retain];

if (error)

nslog(@"getfilesize error: %@", error);

return no;

long nfilesize = [dictfile filesize]; //得到檔案大小

[dictfile release];

在nsdictionary宣告裡,還可以找得到檔案修改時間,檔案型別等資訊

@inte***ce nsdictionary (nsfileattributes)

- (unsigned long long)filesize;

- (nsdate *)filemodificationdate;

- (nsstring *)filetype;

獲取本地檔案大小

文章 report z barry test.data size type i.call method cl gui frontend services file get size exporting file name c fangwen.bmp importing file size size ...

linux 檢視當前資料夾大小 檔案大小

1 ls ll,位元組形成顯示 root ubuntu home aa ls ll total 48 drwxr xr x 2 aa aa 4096 dec 12 2019 desktop drwxr xr x 2 aa aa 4096 dec 12 2019 documents drwxr xr ...

Perl取檔案大小以及檔案測試引數

perl取檔案大小 my args stat filename my size args 7 stat 函式返回乙個陣列。下面是陣列各元素的含義。0 dev 裝置號 驅動器號 c 通常是2,d 通常是3,等等 1 ino 索引節號 總是0 2 mode 檔案的方式 無 3 nlink 鏈結號 通常為...