So I'm writing an xml file to the local Storagefolder
using Windows.Storage;
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
And i would like to view this file in the Windows Explorer for debug purposes.
Is there any way?
It is located under
C:\Users\*Username*\AppData\Local\Packages\*application specific letters and numbers*\LocalState
You can easily determine the path by exploring the Path property of your localFolder object.
All your application data are in \Users\\Appdata\Local\Packages.
Choose your application, and go in the LocalState folder.
Related
I started with UWP platform apps and I want create new folder in Temp folder:
StorageFolder temporaryFolder = ApplicationData.Current.TemporaryFolder;
temporaryFolder = await temporaryFolder.CreateFolderAsync
(Path.GetFileNameWithoutExtension(Path.Combine(temporaryFolder.Path, fileName)),
CreationCollisionOption.ReplaceExisting);
Everything looks OK, but when I want to decompress a ZIP file, which is in Temporary folder into folder which one I created then I give exception:
System.UnauthorizedAccessException: Access to the path 'C:\Users\Admin\AppData\Local\Packages\cebff192-8162-4800-9f9c-b3ce1ca8849f_5gyrq6psz227t\TempState\1' is denied.
My question is simple: How I can create a new folder in Temp to which I can write?
You should be able to access the file in the temporary Folder, but it depends on how you access it. When you access the file, please avoid using the file path. See this blog: https://blogs.msdn.microsoft.com/wsdevsol/2012/12/04/skip-the-path-stick-to-the-storagefile/
To open and read a file in the temporary app data store, use the file APIs, such as Windows.Storage.StorageFolder.GetFileAsync. You can get more details about the temporary folder from Temporary app data.
I need to access a subfolder in the application folder whose path is:
C:\Users\myname\Documents\Visual Studio 2015\Projects\App2\App2\Templates
and retrieves all the data inside. I need to read the xml files in a subfolder of it, parse them, and store them in a dictionary. I have the parsers ready but just don't know how I can access the folder?
I tried
StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFolder templateFolder = await localFolder.GetFolderAsync("Templates");
But it didn't work. An error occurred indicating that folder "Templates" could not be found. However, when I tried "Assets" instead, which had been in the folder ever since the project was created, it worked. How can I access it?
If Template folder is in your project, then you can get it via:
var TempFile = "ms-appx:///Templates/Yourfile.jpg";
I have some folders and inside folders there are some files.i want to get the names of the folder(by iterating) and want to iterate through them to read the files.How can i achieve this in windows phone?
This will give you the installed folder on wp8,
StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
To access the files you can read more here Accessing files in wp8
I am developing an App for Windows Store.
I have to save a recorded media as "file1.mp3" into the Assets folder without opening the save file prompt. I used the following code
StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFileAsync(#"Assets\file1.mp3",Windows.Storage.CreationCollisionOption.ReplaceExisting);
However the system returns an "access denied" error. The file has to be saved in the Assets directory only and I do not want to use FileSavePicker. Please Help.
Thanks
Your package folder is read-only. Use your app data folders from Windows.Storage.ApplicationData.Current instead, wherein you'll find a LocalFolder and TemporaryFolder (also RoamingFolder but an mp3 would exceed the 100KB roaming limit). Then you can use either folder's CreateFileAsync.
I want to create a directory with some config file on the installation process and user home directory. My questions are:
-> how to create this directory while installing
-> how to access home directory from c# code
You have access to some special folders for your application. You can save a file to the LocalFolder like this:
var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("config.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(file, "Text to write to file");
and then retrieve it:
file = await ApplicationData.Current.LocalFolder.GetFileAsync("config.txt");
There's also a RemoteFolder for files you want available to the user if they use your application on another device.
This folder can be found by going to something like "C:\Users\USERNAME\AppData\Local\Packages" and then finding the folder for your app.