folder path exist problem

Discussion in 'Mac Programming' started by saleh.hi.62, Nov 11, 2011.

  1. saleh.hi.62 macrumors member

    Joined:
    Jul 25, 2011
    #1
    hello guys,

    i am trying to validate, if the certain folder in a path exist or not! i checked this code:
    Code:
    NSFileManager *filemgr
    	BOOL s=[filemgr fileExistsAtPath:@"/Extra" ];
    	
    	if (s== NO) {
    		NSLog(@"This path does not exist or its existence could not be determined!");
    		
    	}else {
    		NSLog(@"path exist.");
    	}
    but eventhough /Extra is a valid path it return NO yet!
     
  2. Matthew Yohe macrumors 68020

    Joined:
    Oct 12, 2006
    #2
    So, /Extra... Where exactly is that on your hard drive?

    Because you're saying that it's located at the root of your hard drive.
     
  3. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #3
    You haven't initialised fileMgr. So it's nil. So any message sent to it will be a no-op. Any return value from the no-op will be binary zero. Which when interpreted as a BOOL is NO.

    You can get a NSFileManager object with [NSFileManager defaultManager].
     
  4. Matthew Yohe macrumors 68020

    Joined:
    Oct 12, 2006
    #4
    Ah yes, what jiminaus said as well. (I figured the method you used was a class method but nope! :))
     
  5. saleh.hi.62 thread starter macrumors member

    Joined:
    Jul 25, 2011

Share This Page