Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:29:48+00:00 2026-05-28T15:29:48+00:00

I already get path for documents directory and create some directories inside. I already

  • 0

I already get path for documents directory and create some directories inside. I already know how to check if directory exist, delete it or its files but, how could I list directories? Thank you.

for file listing I use:

int Count;
    NSString *path;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"SomeDirectoryName"];
    NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL];
    for (Count = 0; Count < (int)[directoryContent count]; Count++)
    {
        NSLog(@"File %d: %@", (Count + 1), [directoryContent objectAtIndex:Count]);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:29:50+00:00Added an answer on May 28, 2026 at 3:29 pm

    For example, this method removes all files from temporary directory of application:

    - (void)cleatTmpDirectory
    {
        // Create a local file manager instance
        NSFileManager *localFileManager = [[NSFileManager alloc] init];
        NSURL *directoryToScan = [NSURL fileURLWithPath:[self applicationTmpDirectory]];
    
        NSDirectoryEnumerator *dirEnumerator = 
        [[localFileManager enumeratorAtURL:directoryToScan
                includingPropertiesForKeys:[NSArray arrayWithObjects:NSURLIsDirectoryKey,nil]
                                   options: NSDirectoryEnumerationSkipsHiddenFiles             |   
          NSDirectoryEnumerationSkipsSubdirectoryDescendants | 
          NSDirectoryEnumerationSkipsPackageDescendants
                              errorHandler:nil] retain];
    
        NSError *error;
        // Enumerate the dirEnumerator results, each value is stored in allURLs
        for (NSURL *theURL in dirEnumerator)
        {
            // Retrieve whether a directory. 
            NSNumber *isDirectory;
            [theURL getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL];
    
            if ([isDirectory boolValue] == NO)
            {
                [localFileManager removeItemAtURL:theURL error:&error];
            }
        }
    
        // Release the localFileManager.
        [localFileManager release];
    }
    

    As you can find you should use NSDirectoryEnumerator *dirEnumerator and pass to its initialization method appropriate keys that you will then use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know PHP 5 already supports SQLite but for some reason I can't get
I looked http://docs.djangoproject.com/en/dev/howto/static-files/ already, but am still confused on how to get css/image files
Simply put; what does my $99 get me, that I can't already get for
Suppose I was given a URL. It might already have GET parameters (e.g. http://example.com/search?q=question
Already implemented performance boosters : - Get compatible image of GraphicsConfiguration to draw on
I get this: Warning: session_start(): Cannot send session cookie - headers already sent by
I'm already thinking about to start using simple GET string. Or I'm not so
I want to get an object from the database if it already exists (based
Right, I'm trying to get a label with text in it (done already obviously),
Ok, I get the incremental build and I'm working on it already, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.