locked
System.IO.File (Win32) replaced with Windows.Storage.Streams (Windows API)?

    Question

  • Good morning,

    I was hoping if someone could let me know if I'm on the correct path here. I have a simple Win32 console application that I've been working on, and I'd like to convert it from that to a Windows Store application. I've noticed a few monkey wrenches in m y plan - I'm a neophyte when it comes to programing and I'm learning much of what I'm doing on the fly using only the reference API documentation. I've been scratching my head for some time now, I might actually considering purchasing a book. :P

                try
                {
                    FileStream capturedURL = File.Create(urlFile);
                    capturedURL.Close();
                }
                catch (UnauthorizedAccessException e)
                {
                    errMsg = e.Message;
                    throw;
                }

    What I'm doing here is creating a file to store ULRs in a text file (a list). Later on in the code, I parse several XML files and pull out URLs and write each to the urlFile. Later I have code that reads the URL, then sends a HTTP request to obtain the Title of the page and then creates a <title>.url file in a specific directory (and apparently the API for that has changed as well to something else in Windows.Storage (I'm currently guessing).

    So, is Windows.Storage the place for me to be playing around in to replace my System.IO.File stuff?

    Monday, December 29, 2014 10:50 AM

Answers

  • Yes, Windows.Storage has replaced System.IO.File in Windows Store Apps. That is also due to the decission to only have an async version of any functionality that might exceed a certain time to complete (which basically includes all IO operations - I believe the limit is 10 ms).

    Using Console Applications to prototype functionality for Store Apps is therefore pretty problematic as a lot of APIs look differently there.

    • Proposed as answer by Oliver Ulm Monday, December 29, 2014 11:50 AM
    • Marked as answer by Mike_Avelar Tuesday, December 30, 2014 10:32 AM
    Monday, December 29, 2014 11:50 AM

All replies

  • Yes, Windows.Storage has replaced System.IO.File in Windows Store Apps. That is also due to the decission to only have an async version of any functionality that might exceed a certain time to complete (which basically includes all IO operations - I believe the limit is 10 ms).

    Using Console Applications to prototype functionality for Store Apps is therefore pretty problematic as a lot of APIs look differently there.

    • Proposed as answer by Oliver Ulm Monday, December 29, 2014 11:50 AM
    • Marked as answer by Mike_Avelar Tuesday, December 30, 2014 10:32 AM
    Monday, December 29, 2014 11:50 AM
  • Yes sir it is, seems to be very problematic. But, for someone who is learning like myself. I think it was a good thing for me to learn it the hard way.

    Now I have to find some other stuff. I did manage to learn how to create a text file using the Windows API - let's just hope I'll remember a few months down the road. LOL

    Tuesday, December 30, 2014 10:32 AM