Reading and Writing in an Existing text file in Windows phone app (Silverlight / WinRT)

2015-08-18 19:57:07来源:作者:人点击

This is a small blog post in which I shall be explaining you how to read and write to an existing text file which is present locally in your project. Let us suppose the text file is having the namemyfile.textand is present under main root directory. Step 1: Now first thing you need to do is to set Build Action to Content. And, change Copy to Output Directory to Copy Always. This will ensure the file itself ships with your application. If it doesn’t, you won’t have a file to read. Step 2: Now you can read and write your text files easily as shown in the code below Windows Phone Silverlight Reading Writing WinRT In WinRT you can access files in the local app data store using the “ms-appdata:///local/” protocol. To access files in the app package, useWindows. ApplicationModel. Package. Current. InstalledLocation. Reading Writing Note: Suppose your file is not located in main directory and is located under the root folderFilesas shown below. Then file name would be Note: You can use the same technique for an xml or json file.