<div><span style="font-weight: bold;"><font size="5" face="微软雅黑">
</font></span></div><div style="text-align: left;"><p> <font size="3">+ (void)createFolder:(NSString *)folderName {</font></p>
<p><font size="3"> NSString *imageDir = [NSString stringWithFormat:@"%@/Documents/%@",
NSHomeDirectory(),folderName];</font></p>
<p><font size="3"> NSLog(@"HomeDir: %@",imageDir);</font></p>
<p><font size="3"> BOOL isDir = NO;</font></p>
<p><font size="3"> NSFileManager *fileManager = [NSFileManager defaultManager];</font></p>
<p><font size="3"> BOOL existed = [fileManager fileExistsAtPath:imageDir
isDirectory:&isDir];</font></p>
<p><font size="3"> if ( !(isDir == YES && existed == YES) )</font></p>
<p><font size="3"> {</font></p></div>
<div style="text-align: center;">
</div><div>
<p><font size="3"> [fileManager createDirectoryAtPath:imageDir withIntermediateDirectories:YES
attributes:nil error:nil];</font></p>
<p><font size="3"> }</font></p>
<p><font size="3"> }</font></p></div>
<p><font size="3"> NSString *imageDir = [NSString stringWithFormat:@"%@/Documents/%@",
NSHomeDirectory(),folderName];</font></p>
<p><font size="3"> NSLog(@"HomeDir: %@",imageDir);</font></p>
<p><font size="3"> NSFileManager *fileManager = [NSFileManager defaultManager];</font></p>
<p><font size="3"> [fileManager removeItemAtPath:imageDir error:nil];</font></p>
<p><font size="3"> }</font></p>
<p><font size="3"> NSString *imageDir = [NSString stringWithFormat:@"%@/Documents/%@",
NSHomeDirectory(),folderName];</font></p>
<p><font size="3"> NSLog(@"HomeDir: %@",imageDir);</font></p>
<p><font size="3"> NSFileManager *fileManager = [NSFileManager defaultManager];</font></p>
<p><font size="3"> [fileManager removeItemAtPath:imageDir error:nil];</font></p>
<p><font size="3"> }</font></p>
<p><font size="3"> + (void)changeFolderName:(NSString *)folderName beforeName:(NSString
*)beforeName {</font></p>
<p><font size="3"> NSFileManager *fm = [NSFileManager defaultManager];</font></p>
<p><font size="3"> NSString *beforeFolder = [NSString stringWithFormat:@"%@/Documents/%@",
NSHomeDirectory(),beforeName];</font></p>
<p><font size="3"> NSString *afterFolder = [NSString stringWithFormat:@"%@/Documents/%@",
NSHomeDirectory(),folderName];</font></p>
<p><font size="3"> [fm createDirectoryAtPath:afterFolder withIntermediateDirectories:YES
attributes:nil error:nil];</font></p>
<p><font size="3"> NSDirectoryEnumerator *dirEnum = [fm enumeratorAtPath:beforeFolder];</font></p>
<p><font size="3"> NSString *path;</font></p>
<p><font size="3"> while ((path = [dirEnum nextObject]) != nil) {</font></p>
<p><font size="3"> [fm moveItemAtPath:[NSString
stringWithFormat:@"%@/%@",beforeFolder,path]</font></p>
<p><font size="3"> toPath:[NSString stringWithFormat:@"%@/%@",afterFolder,path]</font></p>
<p><font size="3"> error:NULL];</font></p>
<p><font size="3"> }</font></p> |
|