public FileStream(string path, FileMode fileMode, FileAccess fileAccess, FileInfo fileInfo) { if (fileInfo == null) { fileInfo = new FileInfo(path); } _name = fileInfo.GetCanonicalPath(); if ((fileAccess != FileAccess.Read) && (fileAccess != FileAccess.ReadWrite)) { throw new Exception("IllegalArgumentException: fileAccess"); } _isWriteable = (fileAccess == FileAccess.ReadWrite); if (fileInfo.Exists()) { try { _data = WindowEx.Atob(LocalStorage.GetItem(_name)); _length = _data.Length; } catch (Exception e) { throw (e.Message.StartsWith("IOException") ? new Exception("FileNotFoundException:" + e) : e); } } else if (_isWriteable) { _data = ""; _isDirty = true; try { Flush(); } catch (Exception e) { throw (e.Message.StartsWith("IOException") ? new Exception("FileNotFoundException:" + e) : e); } } else { throw new Exception("FileNotFoundException:" + _name); } }