What need I do to get this code to work in a Portable Class Library?

后端 未结 4 1424
一向
一向 2020-12-21 19:28

I\'m wondering if the Portable Class Library is even more restricted in functionality than the Compact Framework.

I\'m trying to port a CF/Windows CE app (runs on a

4条回答
  •  臣服心动
    2020-12-21 20:12

    Since in a PCL I was unable to get a StreamWriter from a string (it required a stream), I created a simple interface to get some of the data from the platform implementation. You can also do this with DirectoryInfo and FileInfo.

    https://github.com/sami1971/SimplyMobile/blob/master/Core/SimplyMobile.Text/IStreamLocator.cs

    The implementation is really simple as well, only needs one single compiler flag for WP8:

    https://github.com/sami1971/SimplyMobile/blob/master/WP8/SimplyMobile.Text.Platform/StreamLocator.cs

    Recursively search for *.XML files:

        private static void PrintDirectory(IStreamLocator locator, string dir)
        {
            foreach (var file in locator.GetFileNames(dir, "*.XML"))
            {
                System.Diagnostics.Debug.WriteLine(file);
            }
    
            foreach (var di in locator.GetFolderNames(dir, "*"))
            {
                PrintDirectory(locator, di);
            }
        }
    

提交回复
热议问题