Вопрос

How can I format a pen drive programmatically with particular disc type like fat, exFat, NTFS etc. I am trying in cocoa, please help.

Это было полезно?

Решение 2

Its with NSTask.

NSTask *task = [NSTask new];
[task setLaunchPath:@"/usr/bin/env"];
[task setArguments:[NSArray arrayWithObjects:@"diskutil", @"eraseVolume", @"ms-dos", nmToPD, pathToPD,nil]];

NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
[task waitUntilExit];

Другие советы

Take a look at NSFileManager Class Reference

- (BOOL)removeItemAtPath:(NSString *)path error:(NSError **)error  

or

You can use diskutil command with eraseDisk option

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top