Znalazłem poniższy kod, aby usunąć plik w cel-c, ale chcę tylko usunąć wszystkie pliki z katalogu Caches
i zachować katalog Caches
samo.Cel c: Jak tylko usunąć cały plik z katalogu, ale zachować sam katalog
Czy ktoś może zaproponować metodę, aby to zrobić?
Dzięki
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
if ([filemgr removeItemAtPath: [NSHomeDirectory() stringByAppendingString:@"/Library/Caches"] error: NULL] == YES)
NSLog (@"Remove successful");
else
NSLog (@"Remove failed");
AKTUALIZACJA
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
if ([filemgr removeItemAtPath: [NSHomeDirectory() stringByAppendingString:@"/Library/Caches"] error: NULL] == YES)
NSLog (@"Remove successful");
else
NSLog (@"Remove failed");
[filemgr createDirectoryAtPath: [NSHomeDirectory() stringByAppendingString:@"/Library/Caches"] withIntermediateDirectories:NO attributes:nil error:nil];
Jak o ponowne utworzenie folderu pamięć podręczną po usunięciu? – ohho
Możesz usunąć katalog, a następnie go odtworzyć, chociaż musisz mieć pewność, że masz odpowiednie uprawnienia. – dreamlax
Dobry pomysł, dziękuję –