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.

189,306 times
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • 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.
  • 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()
            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?
    • 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.
    • 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);
  • Accessing Files in Background task..
    1 Posts | Last post December 20, 2012
    • I want to read files from system and update the tiles... by using background is my code of backgroundtask... my code is in c++.
      But i am not able to read the file.. it is working in MainPage.xaml.cpp but not in BackgroundTask... Class1.cpp
      void Class1::Run(IBackgroundTaskInstance^ taskInstance)
      	BackgroundTaskDeferral^ deferral = taskInstance->GetDeferral();
      void Class1::Notifications()
      create_task(KnownFolders::DocumentsLibrary->GetFileAsync("12.txt")).then([this](task<StorageFile^> getFileTask)
          {  auto _sampleFile = getFileTask.get();
      		if (_sampleFile != nullptr){
              create_task(FileIO::ReadTextAsync(_sampleFile)).then([this](String^ fileContent)
      		Sting^ readFile = String^ fileContent;
      	catch(Exception^ ex)
1 - 10 of 16 Items