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 8917281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:26:56+00:00 2026-06-15T05:26:56+00:00

I want to get a folder in my constructor. So, I need a non-async

  • 0

I want to get a folder in my constructor. So, I need a non-async method.

    public static Windows.Storage.StorageFolder getStorageImagesDir()
    {
        Windows.Storage.StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("images", CreationCollisionOption.OpenIfExists).GetResults();

        return folder;
    }

However, System.InvalidOperationException was thrown, if the folder doesn’t exist for the first time. (Somehow the folder is still created, even the exception is thrown)

When folder is already exist, the function works fine.

May I know anything wrong with my code?

In Desktop .NET, Java, Python, … we can perform folder creation, withn a simple single line of API call. For instance, Directory.CreateDirectory in .NET, File.mkdirs in Java, … So, why in Windows Store App, we need to do it in async way? Doesn’t it make simple thing unnecessary complicated?

  • 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-06-15T05:26:57+00:00Added an answer on June 15, 2026 at 5:26 am

    Get the code from someone in MSDN.

    StorageFolder folder = ApplicationData.Current.LocalFolder.CreateFolderAsync("images", CreationCollisionOption.OpenIfExists)
                                   .AsTask()
                                   .Result;
    return folder;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get all folder information of root directory in C#.
I want to get the system icon of a specified folder, but maybe the
i want to create functions what get the folder size. I write small function:
Following How to get folder path from file path with CMD I want to
I want to get the folder path from the file who is running the
I am writing a wordpress plugin, I want to get the sub folder name
I want to get all file names from a folder using Ruby.
I want to get emails from gmail, but I want to get the folder
I want to get the list of application which runs on windows startup programatically.
I want get the time used for a case so I can create an

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.