6
A
回答
19
檢查文件是否存在:
+(BOOL)fileExistsAtAbsolutePath:(NSString*)filename {
BOOL isDirectory;
BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDirectory];
return fileExistsAtPath && !isDirectory;
}
檢查目錄是否存在:
+(BOOL)directoryExistsAtAbsolutePath:(NSString*)filename {
BOOL isDirectory;
BOOL fileExistsAtPath = [[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDirectory];
return fileExistsAtPath && isDirectory;
}