Windows Dev Center

File access sample

This sample shows how to create, read, write, copy and delete a file, how to retrieve file properties, and how to track a file or folder so that your app can access it again. This sample uses Windows.Storage and Windows.Storage.AccessCache API.

 
 
 
 
 
(55)
202,454 times
Add to favorites
4/2/2014
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Unable to access saved file using Stream.
    1 Posts | Last post June 06, 2015
    • I used Pickers to create file (on Desktop) & saved text in it using Streams. I saved the file in StorageApplicationPermissions.MostRecentlyUsedList.
      
      While reading file, I retrieved it from MostRecentlyUsedList. I'm trying to read the file using Streams. 
      But I'm getting error: "Access is denied" when I try to open file using StorageFile.OpenAsync().
      
      What is the reason for the error & what is the possible solution?
  • How do I access a file from onedrive using the xplatform cloud kit?
    2 Posts | Last post March 16, 2015
    • I have been working on this app that will allow access to view a file I have placed in onedrive.  How can I access this file?
    • And where would I place the code in the app.
  • Project Structure
    1 Posts | Last post December 28, 2014
    • I have downloaded C++ Sample and when I open the solution file in Visual Studio 2013 I see Windows Phone project files also uploaded. I dont want this to happen because I dont have SLAT to emulate Windows Phone on my Windows 8.1 O/S.
      
      What should be done so that the solution file asks the user what he/she wants to upload according to his/her choice
  • Read file from Documents to string
    1 Posts | Last post June 23, 2014
    • How read .txt file from Documents Library into string in Page Consructor.
  • Hello How can access the file from written path .
    1 Posts | Last post May 07, 2014
    • StorageFile file = await StorageFile.GetFileFromPathAsync(@"C:\MyApp\mytext.xml");
      I want to access the file like this.
      
      thanks
      pramod
  • Good sample code
    5 Posts | Last post April 22, 2014
  • File not found
    2 Posts | Last post April 20, 2014
    • I´m a begginer and maybe this is a silly question.
      I want to read a .txt from Local folder and I´m using this code:
      
      public async void ReadTimestamp()
      {
         try
         {
            StorageFile sampleFile = await localFolder.GetFileAsync("dataFile.txt");
            String timestamp = await FileIO.ReadTextAsync(sampleFile);
            tb_salida.Text = timestamp;
         }
         catch (Exception)
         {
            tb_error.Text = "Not found";
         }
      }
      
      I always read "Not found", I don´t know what folder I have to use to put my file into it. So the thing is: I don´t know which is the Local Folder. I tried to put my file in many places (Assets, bin, Common...) and the other two upper folders.
       Sorry about my English and thanks.
    • one solution is to place your file in the same location as that of the .exe. make use of the Environment class to get access to this folder
      
      hope this helps!
  • Exception of "KnownFolders.DocumentsLibrary"
    3 Posts | Last post October 23, 2013
    • 1. I can't open the solution using Visual studio Express 2012 for Windows phone in windows phone 8 RTW(SDK 8.0)
      2. When i try to use the "StorageFolder storageFolder = KnownFolders.DocumentsLibrary;"
      in my project, it raises the "NotImplementException". (SDK 8.0)
      
      Can anybody help to answer my question?
      Thanks.
    • 1) This is a Windows 8.1 application. Of course you can't open it in Windows Phone 8.
    • This not run in Windows Phone, for it is needed some adjustments
  • Javascript doesn#t work on Win7 with IE9
    2 Posts | Last post August 16, 2013
    • Hi,
      I tried to use the javascript but it doesn't work.
      I use IE9 on Win7.
      BR
      Markus
    • This is a Windows 8 application and the javascript with HTML is just another way to develop Windows 8 applications.
  • The Write a File doesn't show how to overwrite a file
    3 Posts | Last post February 27, 2013
    • If a file exists, writing to it will only replace the first n bytes that are being written, leaving the rest behind. How can I overwrite a file?
    • Hey David, you can truncate the content of the file by assigning a value to the size property of the acquired read/write stream. In this case if you want to reset only what is left behind you can assign the number of bytes n that you just wrote to the size. You can also start from a clean file if you go assign zero to the size of the stream before you write to it.
    • // Overwite use CreationCollisionOption.ReplaceExisting
         StorageFile file = await crmImgsFolder.CreateFileAsync(TEMPFOLDER_IMAGEPREFIX + id.ToString(), CreationCollisionOption.ReplaceExisting);
1 - 10 of 17 Items