Pregunta

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

¿Fue útil?

Solución 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];

Otros consejos

Take a look at NSFileManager Class Reference

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

or

You can use diskutil command with eraseDisk option

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top