2016-01-03 66 views
2

我使用此代碼爲什麼System.IO的類不可用在我的代碼

var httpClient = new HttpClient(); 
httpClient.DefaultRequestHeaders.TransferEncodingChunked = true; 
var content = new MultipartFormDataContent(); 
var imageContent = new StreamContent (new System.IO.FileStream ("my_path.jpg", 
     System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)); 
    imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse ("image/jpeg"); 
    content.Add(imageContent, "image", "image.jpg"); 
await httpClient.PostAsync(Constants.UploadProfilePic+userId+"/photo", content); 

但如u可以Xamarin工作室的這個圖片中看到 System.Io的許多類不xamarin可用形式。 爲什麼是這樣? https://developer.xamarin.com/api/field/System.IO.FileMode.Open/ 甚至xamarin醫生說應該有..

enter image description here

我是新Xamarin開發和看起來像我失去了一些東西,因爲這是跟我發生多次與其他類/命名空間以及。

即使添加System.Io的裁判.. enter image description here

+1

你有正確的項目參考設置? – ChrisF

+0

我認爲這是因爲Xamarin是特定於Android/iOS的。但是,如果添加了正確的引用,則可以獲取它們。 –

+2

如果這是一個PCL項目,則不支持許多System.IO操作,因爲並非所有基礎平臺都支持它們(Windows Phone僅允許IsolatedStorage)。您將需要使用DependencyService將行爲注入到您的應用程序或PCLStorage等包中。 – Jason

回答

1

對我來說是工作,當我提出從共享PCL項目到iOS項目中的代碼。

相關問題