RaulMonteroc
RaulMonteroc

Reputation: 186

Directory class not showing up in portable class library (PCL) using xamarin

I'm creating a mobile android application and I put all non gui-related logic in a portable class library (PCL). Inside that library I'm trying to do the following

if (!Directory.Exists(path)) {
    Directory.CreateDirectory (path);
}

When building, the compiler says the Directory class is not found even when I imported the namespace (using System.IO) and checked that the reference is there, inside .Net portable Subset.

I tried do the same on the android project it works fine.

Upvotes: 0

Views: 588

Answers (2)

RaulMonteroc
RaulMonteroc

Reputation: 186

As Jason pointed, that what I'm trying to do is not supported. From what I saw I had to options:

  • Use an android class library project instead of a PCL
  • Create an abstraction in the library and derive that abstraction in the android/Ios project.

In the end I decided to go for the first aproach since my project is android-only.

Upvotes: 0

Jason
Jason

Reputation: 89082

A PCL whose targets include Windows Phone (which is the default profile for Xamarin iOS/Android PCLs) will not include System.IO classes, because Windows Phone does not support direct file IO.

Upvotes: 2

Related Questions