private static async void GetFileAsync(StorageFolder knownFolder, string path, Action <WSAStorageFile> result) { StorageFile file = await knownFolder.GetFileAsync(path); WSAStorageFile mappedFile = MapStorageFileToWSAStorageFile(file); result(mappedFile); }
/// <summary> /// Creates a file at the specified path and returns a handle to it, parent folders will be created automatically if necessary. /// If the file already exists it will be overwritten /// </summary> /// <param name="library">The library to start in - you must request permissions for it in the app manifest</param> /// <param name="relativePath">Path to the folder in which to create the file</param> /// <returns>A handle to the created file</returns> public static WSAStorageFile CreateFile(WSAStorageLibrary library, string relativePath) { #if NETFX_CORE || (ENABLE_IL2CPP && UNITY_WSA_10_0) StorageFolder folder = GetStorageFolderForWSAKnownLibrary(library); StorageFile file = folder.CreateFileAsync(relativePath, CreationCollisionOption.ReplaceExisting).AsTask().Result; WSAStorageFile mappedFile = MapStorageFileToWSAStorageFile(file); return(mappedFile); #else return(new WSAStorageFile()); #endif }