locked
Use Windows Phone code in Windows Store project (C#)

    Question

  • I have a one question. Ho can i use code below (Windows Phone) in my Windows Store (Metro application) Project?

    string path;
    IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
    IsolatedStorageFileStream file = storage.OpenFile(path, FileMode.Open);
    BinaryReader reader = new BinaryReader(file);
    Tuesday, April 1, 2014 8:03 AM

Answers

  • Hi Denis_92,

    Seems ContentLength Property is not available in Windows Store app.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, April 8, 2014 8:53 AM
    Moderator

All replies

  • you cant use that code directly. you have to use the storage api from winrt.

    public async void ReadFIle()
            {
                string path = null;
                var localfolder = ApplicationData.Current.LocalFolder;
                var file = await localfolder.GetFileAsync(path);
                var reader = new DataReader(await file.OpenReadAsync());
            }


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, April 1, 2014 9:51 AM
  • Thank you very much. I have a just one litle problem. I most write length of the request  content. So how can in write code below in Windows Store (C#)?

    WebRequest req;

    BinaryReader reader = new BinaryReader(stream);

    req.ContentLength = reader.BaseStrean.Length; -> I need just this in Windows Store.

    Tuesday, April 1, 2014 11:31 AM
  • this?

    string path = null;
                var localfolder = ApplicationData.Current.LocalFolder;
                var file = await localfolder.GetFileAsync(path);
                var reader = new DataReader(await file.OpenReadAsync());
                var properties = await file.GetBasicPropertiesAsync();
                var size = properties.Size;

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Tuesday, April 1, 2014 11:38 AM
  • I dont know, ho can I use this req.ContentLength in Windows Store. The ContentLenght of the request (WebRequest class).
    • Edited by Denis_92 Tuesday, April 1, 2014 11:45 AM
    Tuesday, April 1, 2014 11:43 AM
  • Hi Denis_92,

    Seems ContentLength Property is not available in Windows Store app.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, April 8, 2014 8:53 AM
    Moderator