How to create a directory using PCL

When working with creating a Portable Class Library from the current code for a project, some workarounds are pretty obvious, and some of them are problematic.

System.IO.Directory is non-PCL, and I still need to be able to create a directory before creating files inside them.

How to create a folder in C # without the ability to call Directory.CreateDirectory(..) ?

+4
source share
1 answer

PCL does not have built-in support for file and directory I / O, as this functionality differs from platform to platform. However, to work around this problem, you can reference PCLStorage in a portable class library project.

PCLStorage provides a portable library of abstraction layers for input / output of files and directories that you would specify in your portable class library. In your platform-specific application implementation, you must include the appropriate implementation library for this level of abstraction.

PCLStorage is applicable to the .NET Framework 4 and higher, Silverlight 4 and higher, Windows Phone 7.5 and higher, and Windows Store apps. It relies on async and await , which means that it depends on the Async BCL package when used, for example. with .NET 4, Silverlight, and Windows Phone 7.5.

You can also watch the MvvmCross File Plugin . MvvmCross is portable "by nature," and the File plug-in provides the appropriate file and directory I / O functions as synchronous methods. The MvvmCross portable libraries are currently applicable to the .NET Framework 4.5, Silverlight 4 and above, Windows Phone 7.5 and above, Windows Store, Xamarin.iOS, and Xamarin.Android applications.

+4
source

Source: https://habr.com/ru/post/1493077/


All Articles