2017-06-01 50 views
1

我目前正面临在我的Xamarin PCL Project中使用fileInfo和fileStream相关代码的问题,因为Visual Studio会给出错误说明类型或名称空间名称'FileInfo '找不到。无法在Xamarin Project的PCL项目中使用fileInfo和fileStream

我已经包含了使用系统;并在代码中使用system.IO语句,但它仍然不起作用。

using System; 
using System.IO; 
using IPShare.Models; 
using IPShare.ViewModels; 
using Xamarin.Forms; 
using System.Net; 
using System.Resources; 

using System.Text; 
using System.Threading.Tasks; 
using PCLStorage; 
using System.Net.Http; 


namespace IPShare.Views 
{ 
    public partial class ItemsPage : ContentPage 
    { 
     ItemsViewModel viewModel; 
private async void OnButtonClicked(object sender, EventArgs e) 
     { 


      // Load file meta data with FileInfo 
      FileInfo fileInfo = new FileInfo(path); 

      // The byte[] to save the data in 
      byte[] data = new byte[fileInfo.Length]; 

      // Load a filestream and put its content into the byte[] 
      using (FileStream fs = fileInfo.OpenRead()) 
      { 
       fs.Read(data, 0, data.Length); 
      } 

      // Delete the temporary file 
      fileInfo.Delete(); 
     } 
    } 
} 

由于我是新来的xamarin和C#任何帮助将不胜感激。

回答

相关问题