My Windows 8 application has a global class where there are several static properties, such as:
public class EnvironmentEx { public static User CurrentUser { get; set; } //and some other static properties //notice this one public static StorageFolder AppRootFolder { get { return KnownFolders.DocumentsLibrary .CreateFolderAsync("theApp", CreationCollisionOption.OpenIfExists) .GetResults(); } } }
You can see that I want to use the application root folder somewhere else in the project, so I am making this a static property. Inside the recipient, I have to make sure that the root folder exists, otherwise create it. But CreateFolderAsync is an asynchronous method, here I need a synchronized operation. I tried GetResults() , but he InvalidOperationException . What is the correct implementation? (The .appmanifest package is configured correctly, the folder is actually created.)
source share