public byte[] Read(string filename) { // Debug.WriteLine("Storage: Reading " + filename); byte[] bytes = new byte[] { };; // Opening for read only. try { if (IsoStore.FileExists(filename)) { using (var fileStream = IsoStore.OpenFile(filename, FileMode.Open, FileAccess.Read)) { bytes = new byte[fileStream.Length]; fileStream.Read(bytes, 0, bytes.Length); } } } catch (FileNotFoundException) { } catch (IsolatedStorageException) { } /*finally * { * }*/ return(bytes); }
private static string TryGetFileName() { string dateTimeAsString = DateTime.Now.Ticks.ToString(); string logLine = $"Log{dateTimeAsString}.txt"; if (IsoStore.FileExists("Log.txt")) { if (!IsoStore.FileExists(logLine)) { IsoStore.CopyFile("Log.txt", logLine); } else { return(TryGetFileName()); } } return(logLine); }
public override byte[] Read(CacheItemInfo item) { var fi = new FileItem(item); byte[] bytes = null; lock (LockObject) { if (!IsoStore.FileExists(fi.FileName)) { return(null); } using (Stream stream = IsoStore.OpenFile(fi.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); } } return(bytes); }