flo*_*411 9 storage cross-platform portable-class-library xamarin
我在寻找一种方式来存储使用我的本地文件系统的图像文件PCL存储插件在我的核心项目Windows Phone,Xamarin.Android以及Xamarin.iOS.但是,插件只提供了编写Text的方法.什么关于字节.有没有办法保存字节数组?
Dav*_*ave 22
这样的事情怎么样:
IFile file = await FileSystem.Current.GetFileFromPathAsync(fs.filepath);
byte[] buffer = new byte[100];
using (System.IO.Stream stream = await file.OpenAsync(FileAccess.ReadAndWrite))
{
stream.Write(buffer, 0, 100);
}
Run Code Online (Sandbox Code Playgroud)
编辑:一些代码来自http://pclstorage.codeplex.com/
IFile file = await folder.CreateFileAsync("myfile.abc", CreationCollisionOption.ReplaceExisting);
Run Code Online (Sandbox Code Playgroud)
获得IFile对象后,您应该能够以相同的方式使用它:
IFile file = await folder.CreateFileAsync("myfile.abc", CreationCollisionOption.ReplaceExisting);
byte[] buffer = new byte[100];
using (System.IO.Stream stream = await file.OpenAsync(FileAccess.ReadAndWrite))
{
stream.Write(buffer, 0, 100);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14193 次 |
| 最近记录: |