0

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

Shardul
  • 4,266
  • 3
  • 32
  • 50

2 Answers2

1

Take a look at NSFileManager Class Reference

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

or

You can use diskutil command with eraseDisk option

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
0

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];
Shardul
  • 4,266
  • 3
  • 32
  • 50