Accessing files from Windows Store App - windows-store-apps

I'm working in Windows 8 Operating System building Windows Store apps.
I'm trying to access one XML file(present within the solution) via the code below.
var file = System.Xml.Linq.XDocument.Load(#"E:\Gowtham\Data.xml");
But I'm getting "Access to the path 'E:\Gowtham\Data.xml' is denied.'" exception.
I tried all possible ways to remove the read-only attribute of the folder and the file but no use.
I used command prompt to change the attributes of the file, also I tried manually but the read-only attribute of that folder is not changed.
Kind help pls.

You can't get ANY file like that way. I highly recommend you to read these links. You can access files from library if you have declared library access capability.
File system places accessible through WinRT API
Windows 8: The right way to Read & Write Files in WinRT

Related

How to access a OS X user's file system with React VR?

I'm developing an Electron app that is running an instance React VR. The app enables a user to add and save content to a react-vr project by reading and writing the state from/to a JSON file. During development, this JSON file has been stored in the root directory. However, if a user is to download and use the app on their computer, the JSON file needs to be moved outside the app package contents folder.
I have tried using app.getpath('userdata') which returns /Users/'username'/Library/Application Support/'app_name', and I can move the JSON state file there successfully upon running the app. However, I don't know how to have react-vr access this file, especially since there is no access to the computer's file system. However, all I really need is the user's system username to include in the 'userdata' file path.
What's the best way to go about retrieving the username from within react-vr? Would there be a better way to persist user data instead of a using a JSON file to keep track of the state? Would it be worth considering using AsyncStorage in conjunction with a database? Many thanks.

AS3 write string to an existing text file

I'm running my program on AIR. I want my game to save the high score to a text file so it can be stored when the program is closed. I've tried using filestreams, however I've found that the application directory is read only. Is there a better way to do this?
The AIR application storage directory is designed for saving these sorts of preferences and user settings:
For every AIR application, there is a unique associated path that
defines the application storage directory. This directory is unique to
each application and user. You can use this directory to store
user-specific, application-specific data (such as user data or
preferences files).
Access it through the File class:
var file:File = File.applicationStorageDirectory;
file = file.resolvePath("prefs.xml");
See also: Reading from and writing to an XML preferences file
The only caveat I have found with using this directory is that it does not get removed when the AIR app is uninstalled using the .air installer/uninstaller.

LibGDX: Why is Gdx.files.internal() working and Gdx.files.local() not?

HI I am trying to run a LibGDX application on Android and I try to load a JSON File where I need read/write access.
That file is in the assets folder.
When I try to load it with Gdx.files.local("file.json"), it says that it cannot be found (it works with Gdx.files.internal(), however then it is read-only).
Actually, that worked well in another project, and, somehow, now it does not.
I searched for an answer and I cannot find anything, do you have an idea how to solve that problem?
According to the documentation of Libgdx FileHandle types, the Local and Internal FileHandles use a different path under the hood:
- The Internal FileHandle is relative to the assets directory on Android and has a fall back to the ClassPath FileHandle. It is always read-only!
- The Local FileHandle is relative to the internal (private) App-Storage on Android. You can use this FileHandle to read and write.
So basicly it is not possible to write to a file in the internal stoarage, use the local storage instead.
As you want to "ship" this file with your application, you might want to copy it from internal to local storage when the app is started for the first time, so that the application has read and write access to it.

write and read html file from webview windows 8 store app

I have a requirement to produce reports in html (So they can be styles via css etc...) The application is a Windows 8 Store App.
I have created a template and am able to produce the html file. I initially saved it here
Windows.ApplicationModel.Package.Current.InstalledLocation
Great right? wrong! The WebView control will not read from that location!
I also tried writing to the Assets folder of my app. Nope! Permission Denied.
Windows 8 store apps have limited rights to the folder system.
Question:
Where can I put dynamically generated html files (run time) so that they can be read by the WebView Control?
Thanks for any feedback.
In case anyone else has had this problem, or like me you are new to windows store development. Here is the answer (Got help from pluralsight)
Code:
StorageFile file = await destFolder.GetFileAsync(fileName);
string url = "ms-appdata:///local/Estimates/" + fileName;

Can I use asp FileUpload to select a folder?

I need something like the FileUpload control in asp.net that will allow the user to browse for a folder and enter a file name of a new file to upload.
From what I've seen FileUpload requires a file to be selected. It seems that html input type="file" has the same requirement.
Thanks!
Selecting an entire folder is not possible in FileUploadControl as it is meant for a single file. Although you can have a Multi File Selection. Multiple File Upload User Control
C# has build-in FTPrequest class where you can create folders, upload files, delete files etc.
If you want to upload folders from a webpage, you cannot use this technology in the browser, then you will have to use a rich-client such as Java, Flash or similar plugin.
If you can provide the users with a Windows or Mac client, you can use C# (either .NET or Mono) for the FTP transfer.
ZIP files arent a problem for ASP.net nor C#, but you still only upload 1 file (zip-archive) and then its up to the server to unzip it using eg. C#. Look at 7-Zip which is opensource, then you might get some ideas too.
You could also just try and use the build-in lib for it (compression):
http://www.eggheadcafe.com/community/csharp/2/10050636/how-to-compress-and-decompress-file-in-c.aspx
or try this link...
http://www.aurigma.com/docs/iu7/uploading-folders-in-aspnet.htm