title: Cannot create a folder in Iphone but works in simulator
body: <p>I have something like this in my code</p>
  
  <pre><code>if(![[NSFileManager defaultManager] createDirectoryAtPath:uploadDirPath withIntermediateDirectories:true attributes:nil error:nil]) {
              HTTPLogError(@"Could not create directory at path: %@", uploadDirPath);
          }
  </code></pre>
  
  <p>The contents of <code>uploadDirPath</code> is this :</p>
  
  <pre><code>/Users/UserJ/Library/Developer/CoreSimulator/Devices/535C67AB-F932-417B-8CC3-9A813F4F402C/data/Containers/Data/Application/347FA1B2-F790-46A6-B0D6-B638CF2F43F0/Music/
  </code></pre>
  
  <p>The above code works fine in the simulator but when I run it in my phone it gets into the condition saying it cant create the folder.</p>
  
  <p>The content of the string when it shows up on my phone is</p>
  
  <pre><code>/var/mobile/Containers/Data/Application/3E115818-0619-46B0-BD13-BD35EFDF50E3/Music/
  </code></pre>
  
  <p>Any suggestions on why it cant create the folder on my phone ?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>This is the code that comes before </p>
  
  <pre><code>NSArray* dirPaths = NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES);
  NSString* MusicDir = [dirPaths objectAtIndex:0];
  
  //------
  MultipartMessageHeaderField* disposition = [header.fields objectForKey:@"Content-Disposition"];
  NSString* filename = [[disposition.params objectForKey:@"filename"] lastPathComponent];
  //--------
  
  if ( (nil == filename) || [filename isEqualToString: @""] ) {
      // it's either not a file part, or
      // an empty form sent. we won't handle it.
      return;
  }    
  //NSString* uploadDirPath = [[config documentRoot] stringByAppendingPathComponent:@"upload"];
  NSString* uploadDirPath = [MusicDir stringByAppendingString:@"/"];
  
  
  BOOL isDir = YES;
  if (![[NSFileManager defaultManager]fileExistsAtPath:uploadDirPath isDirectory:&amp;isDir ]) {
      [[NSFileManager defaultManager]createDirectoryAtPath:uploadDirPath withIntermediateDirectories:YES attributes:nil error:nil];
  }
  
  NSString* filePath = [uploadDirPath stringByAppendingPathComponent: filename];
  if( [[NSFileManager defaultManager] fileExistsAtPath:filePath] )
  {
      //Delete this file if it exists
      [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
  }
  </code></pre>
  
  <p>I noticed that the array when run on Iphone is empty but when it runs on simulator its fine</p>
  
  <pre><code>NSArray* dirPaths = NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES);
  </code></pre>