title: iPhone - properties of a file
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4134618/iphone-file-properties">iPhone - file properties</a>  </p>
  </blockquote>
  
  
  
  <p>Hi all. i m creating an application which makes the iphone work as a pendrive for easy file sharing purpose.</p>
  
  <p>In the first stage, i have some files(png, pdf, jpg, zip) in a directory and i made them display in the tableview in the form of mutable array without the extensions of each file. </p>
  
  <p>In the second stage i have a detailedViewController which then displays the detailed view of the files like</p>
  
  <ol>
  <li>file size</li>
  <li>file type</li>
  <li>if it is a image, it should open in imageView</li>
  <li>if it is a song, it should play it</li>
  </ol>
  
  <p>So i need to retrieve the properties like filePath, fileType, fileSize.. of each files. Now i got stuck in getting those properties like fileSize and fileType... Please help me proceed with a sample source code.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>- (void)listFiles {
  
  NSFileManager *fm =[NSFileManager defaultManager];
  NSError *error = nil;
  NSString *parentDirectory = @"/Users/akilan/Documents";
  NSArray *paths = [fm contentsOfDirectoryAtPath:parentDirectory error:&amp;error];
  if (error) {
      NSLog(@"%@", [error localizedDescription]);
      error = nil;
  }
  directoryContent = [[NSMutableArray alloc] init];
  for (NSString *path in paths){
      documentsDirectory = [[path lastPathComponent] stringByDeletingPathExtension];
      NSLog(@"%@", documentsDirectory);
      [directoryContent addObject:documentsDirectory];
  
  }
  </code></pre>
  
  <p>Thanks in advance..</p>