title: How to get and set correct current path
body: <p>in my simple command line program, I try to write a string into a text file,</p>
  
  <pre><code>[str writeToFile:@"myfile.txt" atomically:YES encoding:NSUTF8StringEncoding error:nil];
  </code></pre>
  
  <p>when I run my exec file via finder, I expect "myfile.txt" be created in the same folder that exec file is, but it was made in "/users/me"</p>
  
  <p>later I tried to get current path of my program via these codes</p>
  
  <pre><code>NSFileManager *filemgr;
  NSString *currentpath;
  filemgr = [[NSFileManager alloc] init];
  currentpath = [filemgr currentDirectoryPath];
  NSLog(@"Current path is : %@",current path);
  </code></pre>
  
  <p>and I found out that regardless of the location of my exec file, the current path always is "/users/me".  is there any way to get correct path?</p>