Which five actions should you perform in sequence?

DRAG DROP
You are developing a Windows Store app by using JavaScript. The app will use the fileStream object
to write text to a file. You need to write the text to the file and ensure that the file is available to
other apps. Which five actions should you perform in sequence? (To answer, move the appropriate
actions from the list of actions to the answer area and arrange them in the correct order.)

DRAG DROP
You are developing a Windows Store app by using JavaScript. The app will use the fileStream object
to write text to a file. You need to write the text to the file and ensure that the file is available to
other apps. Which five actions should you perform in sequence? (To answer, move the appropriate
actions from the list of actions to the answer area and arrange them in the correct order.)

Answer:

Explanation:



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Vadim

Vadim

It’s confusing…

If we use DataWriter, then the steps are:

1.Create a DataWriter object to write text content
2. Commit data in the DataWriter object
3. Flush data in the DataWriter object
4. Close the fileStream object

var dataWriter = new Windows.Storage.Streams.DataWriter(iOutputStream);

writer.writeString(element);

// The call to store async sends the actual contents of the writer
// to the backing stream.
//The call to StoreAsync commits data in the buffer to a backing store.

writer.storeAsync().then(function () {
// For the in-memory stream implementation we are using, the flushAsync call
// is superfluous, but other types of streams may require it.
return writer.flushAsync();

writer.close();

Please refer to:
http://msdn.microsoft.com/library/windows/apps/BR208154

Vadim

Vadim

Found another MSDN article that suggests

1. Create a sequential output stream…
2. Create a DataWriter object to write text content
3. Commit data in the DataWriter object
4. Flush data in the streamContent object
5. Close the fileStream object

The steps mentioned in the article:

Writing text to a file by using a stream
==========================================
1.Open a stream over your file by calling the StorageFile.OpenAsync method. It returns a stream of the file’s content when the open operation completes.
2. Get an output stream by calling the GetOutputStreamAt method from the stream. Put this in a using statement to manage the output stream’s lifetime.
3. Write text to the outputStream by creating a new DataWriter object and calling the DataWriter.WriteString method.
4. Save the text to your file and close the stream by calling the writer.StoreAsync and outputStream.FlushAsync methods.

Please refer to:
http://msdn.microsoft.com/en-us/library/windows/apps/hh758325.aspx