How to include a text file ?


  • I want to add some text file into Assets folder.

    For example, License.txt or text based difinition file...

    I want to read those files from Assets folder.

    Is it possible ?

    Currently I cannot access those files.

    I use some difinition file in my Windows Desktop application.

    I want to use same file for Metro app.

    Currently I create resource.resw, and insert all text string of the file in it as a string.


    Tuesday, July 10, 2012 4:26 AM


All replies

  • Hi Kata,

    Is there a particular reason for using the Assets Folder? You can use the ApplicationData.LocalFolder to create files and use them in your application. You can also, use the LocalFolder to create new files in it.


    Tuesday, July 10, 2012 5:14 PM
  • Hi Sagr,

    Thank you for comment.

    I don't need to use Assets folder.

    I know ApplicationData class, I can save application settings in it.

    For example, I want to add license.txt into a Appx package.

    Then Metro app read it and set it to Textblock control.

    Is it possible ?


    Tuesday, July 10, 2012 11:22 PM
  • Hi Kata,

    You can add your license.txt file to the project and mark it as Content. It will be copied to the Appx package when the package is built.


    Tuesday, July 10, 2012 11:29 PM
  • Hi Rob,

    Thank you for comment.

    May be, license.txt will be locatedd in the folder below.

    C:\Program files\WindowsApps\(package name-

    But I don' know how to access.

    file open function usually returns Access Denied.

    How to specify the folder which the licenset.txt exist ?

    Could you please show me the sample code?

    I'm using C++. :-)


    Wednesday, July 11, 2012 3:17 AM
  • You can get a StorageFolder for your package's directory with Package->Current->InstalledLocation 

    How are you trying to open the file that it returns Access Denied? It helps if when you describe your problem you include minimal sample code to demonstrate what you are doing, exact repro steps, and a clear description of the expected behavior and how it differs from the actual behavior.


    Wednesday, July 11, 2012 6:55 AM
  • Thank you!

    Now I'm working for a beta version of program...

    I'll try to check it again on this Saturday, maybe.

    If I will not be able to success, I will post my simple code.


    • Edited by kata._ Wednesday, July 11, 2012 9:33 AM
    Wednesday, July 11, 2012 9:26 AM
    • Marked as answer by kata._ Friday, July 13, 2012 6:04 AM
    Wednesday, July 11, 2012 10:26 AM
  • Hi haibo.lue,

    Thank you for the link.

    I will check them, and I will post the result. :-)


    • Edited by kata._ Wednesday, July 11, 2012 10:40 AM
    Wednesday, July 11, 2012 10:38 AM
  • Hi Rob,

    I could read license.txt from the installed location.

    Many thanks for your advice!!


    Friday, July 13, 2012 6:04 AM
  • Hi haibo,

    Thank you !

    I could read a file from installed folder.


    Friday, July 13, 2012 6:05 AM