public static bool Save(ImageFolder sub_folder, string filename, byte[] data) { IFolder rootFolder = Plugin.NetStandardStorage.CrossStorage.FileSystem.LocalStorage; IFolder folder = rootFolder.CreateFolder(sub_folder.ToString(), CreationCollisionOption.OpenIfExists); IFile file = folder.CreateFile(filename, CreationCollisionOption.ReplaceExisting); using (Stream stream = file.Open(FileAccess.ReadWrite)) { stream.Write(data, 0, data.Length); } return(true); }
public static byte[] Load(ImageFolder sub_folder, string filename) { IFolder rootFolder = Plugin.NetStandardStorage.CrossStorage.FileSystem.LocalStorage; IFolder folder = rootFolder.CreateFolder(sub_folder.ToString(), CreationCollisionOption.OpenIfExists); if (!folder.CheckFileExists(folder.FullPath + "/" + filename)) { return(null); } IFile file = folder.GetFile(filename); using (Stream stream = file.Open(FileAccess.ReadWrite)) { long length = stream.Length; byte[] streamBuffer = new byte[length]; stream.Read(streamBuffer, 0, (int)length); return(streamBuffer); } }