locked
Read local file in Portable Library RRS feed

  • Question

  • I am writing windows 8 app and Windows Phone 8 App. I need both of these apps to process some data using exact same algorithms. I had decided to write a portable class library in C# for these algorithms. So each of the apps, windows 8 and windows phone 8 will call into the DLL for data processing.

    However, i need to access local file path, passed from app to the DLL. How do i achieve that?

    I know StreamReader(Stream) is Portable, but i m not sure how to create and pass the stream case in the above situation?

    thanks,

    Beginner C# programmer.

    Monday, March 18, 2013 5:53 PM

Answers

All replies

  • File access cannot be done portably between Windows Store apps and Windows Phone 8 apps. You will have to use platform specific code, to open the file and acquire a stream. You can then pass the stream into the PCL.

    Since both Windows Store apps and Windows Phone 8 apps use the essentially the same Windows (Phone) Runtime classes from Windows.Storage to open files you can share the code (but not the binary) by linking a code file between the two projects. See Share code with Add as Link .

    See Maximize code reuse between Windows Phone 8 and Windows 8 for more techniques for sharing code.

    --Rob

    Monday, March 18, 2013 10:43 PM
    Moderator
  • How can i return output file from a class libary to the Store or Phone app?
    Wednesday, March 20, 2013 9:34 PM
  • Rob's answer is correct, but you may also want to consider using PCL Storage to access persisted storage from a Portable Class Library.
    Friday, August 9, 2013 12:48 AM