Hi,
I'm developing an application and I'd like to know, if there is any way to access filesystem (R/W)?
Hi,
I'm developing an application and I'd like to know, if there is any way to access filesystem (R/W)?
It depends on what file system you want to access(if you open the link, API-s for this isolated storage stuff are described nearby)Originally Posted by http://msdn.microsoft.com/en-us/library/ff402541(v=VS.92).aspx
Isolated storage is a filesystem that only your app can see, it can't access other parts of the phone.
If you are from j2me background then something similar to recordstore , there is no api as such so far to access files
Hi,
wizard_hu is right.
see below link also.
http://social.msdn.microsoft.com/For...6-8d065bf57989
http://www.codebadger.com/blog/post/...s-Phone-7.aspx
Hi Mimuurin,
There is no direct access to the operating system's file system.To access the file system in Windows Phone 7, you can use the Isolated Storage. it is a Virtual File System. Isolated storage allows you to store data locally. There are two ways to use isolated storage.
- The first way is to save or retrieve data as key/value pairs by using the IsolatedStorageSettings class.
- The second way is to save or retrieve files by using the IsolatedStorageFile class.
This improves security and reduces chances of unauthorized access and data corruption.
Hope it helps.
Last edited by pavan.pareta; 2011-07-19 at 08:28. Reason: Added MSDN Link
Pavan Pareta
Sr. Software Engineer
http://windows-mobile-dev.blogspot.com
Hi All,
I have read through the posts, but was unable to get solution to my problem, very much related to File access.
I have a file, which I want to use in the application. NOTE: This file is already there with me, and i want to use to deploy it. How to put it in IsolatedStorageFile storage or how to embed it into my application, so that it is available for reading.
The files which I want mainly contains some settings information, some localization strings, and some text to display on the screen. So I want these 2 files to be available to me during execution, what is the way ?
To summarize the question:
From the example codes of IsolatedStorageFile - what I could understand is that you can write and then later read the files which are private to you, but how to embed a file along with the application?
Amit Kankani
Nokia Developer Champion
As I understand you can not deploy files to the isolated storage. A thing you can certainly do is deploying them with the .xap, and save them into the isolated storage when you need to modify them.
On the implementation side it affects the loader routine, you try to load data from the file first, and if the file does not exist, you turn to the resource.
Understood now, well I am completely a new bee in WP7...
Next issue then is: how to deploy a txt file...
These are the steps I did to deploy the file:
Create a NewFolder called Resources and placed my.txt inside it
Clicked on the properties of "my.txt" and selected Content for Build Action.
Problem being faced now: How to access it and read its content to string ?
I am trying to use StreamReader, but not successful, here is the code:
I tried some options, but not aware how to access the file (location?) and then how to read from it...Code:StreamReader readFile = null; try { readFile = new StreamReader("Resources\\IndiFontTest.txt"); //FileStream myFileStream = File.Open("Resources\\IndiFontTest.txt", FileMode.Open); //readFile = new StreamReader(new File("Resources\\IndiFontTest.txt", FileMode.Open, myStore)); //readFile = new StreamReader(new IsolatedStorageFileStream("Resources\\IndiFontTest.txt", FileMode.Open, myStore)); string fileText = readFile.ReadToEnd(); //The control txtRead will display the text entered in the file textBlockListTitle.Text = fileText; readFile.Close(); } catch { textBlockListTitle.Text = "A - Need to create directory and the file first."; }
Amit Kankani
Nokia Developer Champion
I am not familiar with WP7 either, but the link in #2, which is also repeated in #6 (and actually referred in the articles linked in #5 too) is a good starting point, really. How about opening it, and checking the How-to articles it offers just above the image?
Otherwise you were close with the attempt, just missed the IsolatedStorageFile class and its static getter![]()
Amit Kankani
Nokia Developer Champion
Ah, we are talking about the .xap part then. It is Application.GetResourceStream as I understand, http://msdn.microsoft.com/en-us/libr...(v=VS.95).aspx, but I have not tried it in action.
Yes, this is what I was looking for... Did a little more digging for text files and not images, and the following code works good :
thanks for the pointersCode:Uri uri = new Uri("Resources/IndiFontTest.txt", UriKind.Relative); StreamResourceInfo sri = Application.GetResourceStream(uri); StreamReader streamReader = new StreamReader(sri.Stream); textBlockListTitle.Text = streamReader.ReadToEnd();![]()
Amit Kankani
Nokia Developer Champion
Hi,
Hope below link its better help.
http://www.windowsphonegeek.com/tips...ave-text-files
thanks, but that is already there in post #2, #6....
If you carefully read, what I was looking for is not storage, but an ability to embed a file, with some contents.
I was able to achieve it from the link given bu wizard_hu_ in post #12
hope u got what is the difference...
Amit Kankani
Nokia Developer Champion