How to write a log or text file to the file system in Metro Style App?
-
יום שישי 13 אפריל 2012 00:24
As the title said, I would like to write an activity log of my application into a file automatically. My application is built in Javascript/HTML5, when I am debugging I can use
console.log("this is a debug log")and track it in console. But if I want to give my test machine to a certain test user, I want to be able to track the activity logs.Is there any way that I can do that? Is there API that I can use to write a file in the file system?
Louis
כל התגובות
-
יום שישי 13 אפריל 2012 01:00
The FileIO Class may work for you. There is a method for appending text to a file:
Windows.Storage.FileIO.appendTextAsync(file, contents).done( /* Your success and error handlers */ );
Your application will have to request permission to write to a file in the user's Documents folder via the manifest and the user will have to agree the first time your application tries to access that directory.
Check out this Quickstart for examples.
Because of the asynchronous nature of these operations, for logging purposes, you should consider sending your messages to a string or array of strings and then writing/appending them to your log file at one time--say when the app is about to suspend.
- נערך על-ידי jrboddie יום שישי 13 אפריל 2012 01:15
- נערך על-ידי jrboddie יום שישי 13 אפריל 2012 01:15
- נערך על-ידי jrboddie יום שישי 13 אפריל 2012 01:16
- נערך על-ידי jrboddie יום שישי 13 אפריל 2012 01:17
- הוצע כתשובה על-ידי jrboddie יום שלישי 24 אפריל 2012 13:11
- סומן כתשובה על-ידי Bob_BaoMVP, Moderator יום שני 30 אפריל 2012 08:26