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#任何幫助將不勝感激。
是的,讀了一些類可以在PCL中感謝:) –