void DeleteFiles(Storage storage, string directoryPath) { foreach (var filename in storage.GetFileNames(directoryPath + "*")) { storage.DeleteFile(directoryPath + filename); } }
private string ReadFile(string filename) { try { // Obtain a virtual store for the application. System.IO.IsolatedStorage.IsolatedStorageFile local = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (local.FileExists("DataFolder\\" + filename)) { // Specify the file path and options. using (var isoFileStream = new System.IO.IsolatedStorage.IsolatedStorageFileStream ("DataFolder\\" + filename, System.IO.FileMode.Open, local)) { // Read the data. using (var isoFileReader = new System.IO.StreamReader(isoFileStream)) { return(isoFileReader.ReadLine()); } } } else { return(null); } } catch { return(null); } }
private void WriteToFile(string content, string filename) { try { // Get the local folder. System.IO.IsolatedStorage.IsolatedStorageFile local = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); // Create a new folder named DataFolder. if (!local.DirectoryExists("DataFolder")) { local.CreateDirectory("DataFolder"); } // Create a new file named DataFile.txt. using (var isoFileStream = new System.IO.IsolatedStorage.IsolatedStorageFileStream( "DataFolder\\" + filename, System.IO.FileMode.Create, local)) { // Write the data from the textbox. using (var isoFileWriter = new System.IO.StreamWriter(isoFileStream)) { isoFileWriter.WriteLine(content); } } } catch { } }
public IsolatedStorageFile(string filename, System.IO.IsolatedStorage.IsolatedStorageFile storage, IsolatedStorageDirectory directory) { this.filename = filename; this.storage = storage; this.directory = directory; systemFilename = filename.Substring(2); // Skip the "~/" prefix. }
protected virtual void ReadFromIsolatedStorage(string fileName) { using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage()) { System.IO.IsolatedStorage.IsolatedStorageFileStream l_File = null; try { l_File = new System.IO.IsolatedStorage.IsolatedStorageFileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, l_Storage); } catch (System.IO.FileNotFoundException) { l_File = null; } if (l_File == null) //file non esiste { } else //file esiste { try { ReadFromStream(l_File); } finally { l_File.Close(); } } l_Storage.Close(); } }
/// <summary> /// /// </summary> public XNArkanoidGame() { State.Game = this; mIsolatedStorage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); XNArkanoidGame.mGameState = eGameState.Loading; mGraphics = new GraphicsDeviceManager(this); mSettings = Settings.Load(); mGraphics.PreferredBackBufferWidth = mSettings.ScreenWidth; mGraphics.PreferredBackBufferHeight = mSettings.ScreenHeight; // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); mVaus = new Vaus(this); // Create dialogs mMainDialog = new UIGame.GUIMainScreen(this); mMainDialog.ControlSelected += new global::XNArkanoid.UI.UIDialog.ControlSelectedDelegate(mMainDialog_ControlSelected); mContinueDialog = new UIGame.GUIContinueScreen(this); mContinueDialog.PlayerContinues += new EventHandler(mContinueDialog_PlayerContinues); mContinueDialog.CounterReachedZero += new EventHandler(mContinueDialog_CounterReachedZero); Level.AllBallsFallen += new Level.AllBallsFallenDelegate(Level_AllBallsFallen); Level.EndLevel += new Level.EndLevelDelegate(Level_EndLevel); XNArkanoidGame.mGameState = eGameState.DialogMain; }
void RemoveExistingCache() { using (var storage = IsolatedStorageFile.GetMachineStoreForAssembly()) { storage.Remove(); } }
private void WriteToDisk(System.IO.IsolatedStorage.IsolatedStorageFile iso, string storeFile) { DataOutputStream dos = FileUtils.WriteIsolatedStorageFileToDataInput(iso, storeFile); try { dos.WriteUTF(HEADER); dos.WriteInt(nextRecordId); dos.WriteInt(records.Count); for (int i = 0; i < records.Count; i++) { RecordItem ri = records[i]; long pSize = ri.data.Length; int pId = ri.id; dos.WriteLong(pSize); dos.WriteInt(pId); dos.Write(ri.data); } } catch (Exception e) { throw new RecordStoreException("Error writing store to disk: " + e.StackTrace); } finally { if (dos != null) { dos.Close(); } dos = null; } }
internal static bool FileExists(string dbpath, string typeName, bool useElevatedTrust) { string extension = ".sqo"; if (SiaqodbConfigurator.EncryptedDatabase) { extension = ".esqo"; } string fileName = dbpath + Path.DirectorySeparatorChar + typeName + extension; #if SILVERLIGHT if (!useElevatedTrust) { System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); return(isf.FileExists(fileName)); } else { return(File.Exists(fileName)); } #elif MONODROID return(File.Exists(fileName)); #else return(File.Exists(fileName)); #endif }
protected virtual void RemoveIsolatedStorage(string fileName) { using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage()) { l_Storage.DeleteFile(fileName); l_Storage.Close(); } }
public InitialConfiguration(CassetteConfigurationSection configurationSection, bool globalIsDebuggingEnabled, string sourceDirectory, string virtualDirectory, IsolatedStorageFile storage) { this.configurationSection = configurationSection; this.globalIsDebuggingEnabled = globalIsDebuggingEnabled; this.sourceDirectory = sourceDirectory; this.virtualDirectory = virtualDirectory; this.storage = storage; }
public IsolatedStorageDirectory_Tests() { storage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly(); foreach (var filename in storage.GetFileNames("*")) { storage.DeleteFile(filename); } }
public IsolatedStorageDirectory_Tests() { storage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly(); foreach (var filename in storage.GetFileNames()) { storage.DeleteFile(filename); } }
public void DeleteIndex() { System.IO.IsolatedStorage.IsolatedStorageFile local = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (local.FileExists("IndicesFolder\\Index.txt")) { local.DeleteFile("IndicesFolder\\Index.txt"); } }
private List <IEpisode> LoadAllEpisodes(string episodeListUrl) { System.IO.IsolatedStorage.IsolatedStorageFile f = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); byte[] data = IOUtil.LoadUrl(episodeListUrl); string allEpisodesHtml = Encoding.ASCII.GetString(data); List <IEpisode> details = new List <IEpisode>(); Regex episodeMatcher = new Regex("<tr class=\"[ t](.*?)</tr>", RegexOptions.Singleline); foreach (Match m in episodeMatcher.Matches(allEpisodesHtml)) { string episodeHtml = m.Groups[1].Value; //Match match = Regex.Match(episode, "<td.*?><a href=\"([^\"]+)\">([^<]+)<", RegexOptions.Singleline); Match match = Regex.Match(episodeHtml, "<td.*?>\\s*<a href=\"([^\"]+)\">([^<]+)<.*?/td>.*?<td[^>]*>\\s*(.*?)\\s*</td>.*?<td class=\"p-5\"[^>]*>(.*?)</td>", RegexOptions.Singleline); if (match.Success) { string url = match.Groups[1].Value; string desc = match.Groups[2].Value; string date = match.Groups[3].Value.Trim(); System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.GetCultureInfo("en-US"); try { DateTime usDate = DateTime.Parse(date, ci.DateTimeFormat); date = usDate.ToString("yyyy-MM-dd"); } catch (FormatException e) { System.Diagnostics.Debug.WriteLine("Unable to process date: " + date + ". Setting to DateTime.MinValue (Error: " + e.Message + ")"); date = DateTime.MinValue.ToString("yyyy-MM-dd"); } string episode = match.Groups[4].Value.Trim(); Match descMatch = Regex.Match(desc, "^\\s+(.*) \\s*?", RegexOptions.Multiline); if (descMatch.Success) { desc = descMatch.Groups[1].Value; } string season = null; Match seasonMatch = Regex.Match(episode, "^(.+?)\\s*-\\s*(.+?)$"); if (seasonMatch.Success) { season = seasonMatch.Groups[1].Value; episode = seasonMatch.Groups[2].Value; } System.Diagnostics.Debug.WriteLine(string.Format("Got season: {0}. episode: {1}. Title: {2}. Url: {3}. Air Date: {4}", season, episode, desc, url, date)); details.Add(new Episode(int.Parse(season), int.Parse(episode), date, desc, new Uri(url))); } } return(details); }
public IsolatedStorageFileWrapper_Tests() { storage = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly(); directory = new IsolatedStorageDirectory(storage); using (var stream = storage.CreateFile("exists.js")) { "content".AsStream().CopyTo(stream); stream.Flush(); } }
public CassetteApplicationTests() { RemoveExistingCache(); storage = IsolatedStorageFile.GetMachineStoreForDomain(); routes = new RouteCollection(); httpContext = new Mock<HttpContextBase>(); httpContextItems = new Dictionary<string, object>(); httpContext.Setup(c => c.Items).Returns(httpContextItems); }
public CassetteApplicationTests() { RemoveExistingCache(); storage = IsolatedStorageFile.GetMachineStoreForAssembly(); routes = new RouteCollection(); httpContext = new Mock <HttpContextBase>(); httpContextItems = new Dictionary <string, object>(); httpContext.Setup(c => c.Items).Returns(httpContextItems); }
void RecursiveDirectoryDelete(Storage storage, string path) { if (path.Length > 0) { path += "/"; } foreach (var subDirectory in storage.GetDirectoryNames(path + "*")) { RecursiveDirectoryDelete(storage, path + subDirectory); } DeleteFiles(storage, path); storage.DeleteDirectory(path); }
void PhotoTask_Completed(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null) { System.Windows.Media.Imaging.WriteableBitmap bmp = Microsoft.Phone.PictureDecoder.DecodeJpeg(e.ChosenPhoto); System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (isf.FileExists("back_temp.jpg")) { isf.DeleteFile("back_temp.jpg"); } System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.CreateFile("back_temp.jpg"); System.Windows.Media.Imaging.Extensions.SaveJpeg(bmp, PhotoStream, 1024, 768, 0, 100); //这里设置保存后图片的大小、品质 PhotoStream.Close(); //写入完毕,关闭文件流 } }
private void Bcakground_Click(object sender, RoutedEventArgs e) { if ((bool)checkBoxSetting.IsChecked) { takePhote(); NavigationService.GoBack(); } else { System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (isf.FileExists("back_temp.jpg")) { isf.DeleteFile("back_temp.jpg"); } } }
/// <summary> /// 尝试读取数据流 /// </summary> /// <param name="resName"></param> /// <returns></returns> public static System.IO.Stream OpenStream(string @resName) { Stream resource = StrRes(resName); if (resource != null) { return(resource); } //尝试读取XAP中文件(Content类型) System.IO.Stream stream = null; try { stream = TitleContainer.OpenStream(resName); } catch { if (stream == null) { //尝试读取DLL中文件(Resource类型) Uri pathUri = new Uri("/" + JavaRuntime.GetAssemblyName() + ";component/" + resName, UriKind.RelativeOrAbsolute); stream = ApplicationResourceStream(pathUri); } } if (stream == null) { //尝试读取标准路径数据 try { stream = new System.IO.FileStream(resName, System.IO.FileMode.Open); } catch { //尝试读取封闭空间中数据 try { System.IO.IsolatedStorage.IsolatedStorageFile store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); stream = store.OpenFile(resName, System.IO.FileMode.Open); } catch (Exception ex) { Log.Exception(ex); Log.DebugWrite("\n" + resName + " file not found !"); } } } return(stream); }
void RemoveExistingCache() { using (var storage = IsolatedStorageFile.GetMachineStoreForAssembly()) { #if NET35 if (storage.GetFileNames("casette.xml").Length > 0) { storage.DeleteFile("cassette.xml"); } #else if (storage.FileExists("cassette.xml")) { storage.DeleteFile("cassette.xml"); } #endif } }
protected virtual void WriteToIsolatedStorage(string fileName, PersistenceFlags flags) { using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage()) { System.IO.IsolatedStorage.IsolatedStorageFileStream l_File = null; l_File = new System.IO.IsolatedStorage.IsolatedStorageFileStream(fileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, l_Storage); try { WriteToStream(l_File, flags); } finally { l_File.Close(); } l_Storage.Close(); } }
public static bool _GetStore_System_IO_IsolatedStorage_IsolatedStorageScope_System_Type_System_Type( ) { //Parameters System.IO.IsolatedStorage.IsolatedStorageScope scope = null; System.Type domainEvidenceType = null; System.Type assemblyEvidenceType = null; //ReturnType/Value System.IO.IsolatedStorage.IsolatedStorageFile returnVal_Real = null; System.IO.IsolatedStorage.IsolatedStorageFile returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(scope, domainEvidenceType, assemblyEvidenceType); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(scope, domainEvidenceType, assemblyEvidenceType); } catch (Exception e) { exception_Intercepted = e; } Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted)); }
public void SaveIndex() { System.IO.IsolatedStorage.IsolatedStorageFile local = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (!local.DirectoryExists("IndicesFolder")) { local.CreateDirectory("IndicesFolder"); } using (var isoFileStream = new System.IO.IsolatedStorage.IsolatedStorageFileStream("IndicesFolder\\Index.txt", System.IO.FileMode.OpenOrCreate, local)) { using (var isoFileWriter = new System.IO.StreamWriter(isoFileStream)) { foreach (var card in Index) { var cardAsString = string.Format("[[{0}]] {1} {2}{3}", card.Key.Trim("\n".ToCharArray()), card.Value.StartsAtByte, card.Value.Length, Environment.NewLine); isoFileWriter.WriteLine(cardAsString); } } } }
protected virtual bool IsolatedStorageExists(string fileName) { fileName = System.IO.Path.GetFileName(fileName).ToLower(); using (System.IO.IsolatedStorage.IsolatedStorageFile l_Storage = GetStorage()) { string[] files = l_Storage.GetFileNames("*"); for (int i = 0; i < files.Length; i++) { string fileFinded = System.IO.Path.GetFileName(files[i]).ToLower(); if (fileFinded == fileName) { return(true); } } l_Storage.Close(); } return(false); }
public bool LoadIndex() { System.IO.IsolatedStorage.IsolatedStorageFile local = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); var newIndex = new Dictionary <string, FileTextBlock>(); if (!local.FileExists("IndicesFolder\\Index.txt")) { return(false); } using (var isoFileStream = new System.IO.IsolatedStorage.IsolatedStorageFileStream("IndicesFolder\\Index.txt", System.IO.FileMode.Open, local)) { using (var isoFileReader = new System.IO.StreamReader(isoFileStream)) { var line = isoFileReader.ReadLine(); while (!isoFileReader.EndOfStream) { if (!string.IsNullOrEmpty(line)) { var firstSpace = line.IndexOf(" ", line.IndexOf("]]")); if (firstSpace > 0) { var secondSpace = line.IndexOf(" ", firstSpace + 1); var wordKey = line.Substring(2, line.IndexOf("]]") - 2); var startsAt = long.Parse(line.Substring(firstSpace + 1, secondSpace - firstSpace).Trim(' ')); var length = int.Parse(line.Substring(secondSpace + 1).Trim(' ')); newIndex.Add(wordKey, new FileTextBlock() { Length = length, StartsAtByte = startsAt }); } } line = isoFileReader.ReadLine(); } } } Index = newIndex; return(true); }
public static bool _GetUserStoreForAssembly( ) { //Parameters //ReturnType/Value System.IO.IsolatedStorage.IsolatedStorageFile returnVal_Real = null; System.IO.IsolatedStorage.IsolatedStorageFile returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly(; } catch( Exception e ) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly(; } catch( Exception e ) { exception_Intercepted = e; } Return ( ( exception_Real.Messsage == exception_Intercepted.Message ) && ( returnValue_Real == returnValue_Intercepted ) ); }
public void IsolatedStorageFileSystem_AccessesIsolatedStorage() { using (var store = IsolatedStorageFile.GetMachineStoreForAssembly()) { using (var writer = new StreamWriter(store.OpenFile("test.txt", FileMode.Create, FileAccess.Write))) { writer.Write("test"); writer.Flush(); } var directory = new IsolatedStorageDirectory(store); var file = directory.GetFile("test.txt"); file.Exists.ShouldBeTrue(); using (var reader = new StreamReader(file.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { reader.ReadToEnd().ShouldEqual("test"); } file.Delete(); store.FileExists("test.txt").ShouldBeFalse(); } }
private void ReadFromDisk(System.IO.IsolatedStorage.IsolatedStorageFile iso, string storeFile) { DataInputStream dis = FileUtils.ReadIsolatedStorageFileToDataInput(iso, storeFile); try { string header = dis.ReadUTF(); if (!header.Equals(HEADER)) { throw new RecordStoreException("Store file header mismatch: " + header); } nextRecordId = dis.ReadInt(); int size = dis.ReadInt(); records.Clear(); for (int i = 0; i < size; i++) { long pSize = dis.ReadLong(); int pId = dis.ReadInt(); byte[] buffer = new byte[pSize]; dis.Read(buffer); RecordItem ri = new RecordItem(pId, buffer); records.Add(ri); } } catch (Exception e) { throw new RecordStoreException("ERROR reading store from disk (" + storeFile + "): " + e.StackTrace); } finally { if (dis != null) { dis.Close(); dis = null; } } }
public static bool _ctor_System_IO_IsolatedStorage_IsolatedStorageFileStream_System_String_System_IO_FileMode_System_IO_IsolatedStorage_IsolatedStorageFile( ) { //Parameters System.String path = null; System.IO.FileMode mode = null; System.IO.IsolatedStorage.IsolatedStorageFile isf = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.IO.IsolatedStorage.IsolatedStorageFileStream.ctor(path, mode, isf); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.IO.IsolatedStorage.IsolatedStorageFileStream.ctor(path, mode, isf); } catch (Exception e) { exception_Intercepted = e; } }
public IsolatedStorageFile(System.IO.IsolatedStorage.IsolatedStorageFile file) { this.file = file; }
public IsolatedStorageDirectory(Storage storage) : this(() => storage, "~/") { }
IsolatedStorageDirectory(System.IO.IsolatedStorage.IsolatedStorageFile storage, string basePath) { this.storage = storage; this.basePath = basePath; }
public IsolatedStorageFileSystem(Store store) { _store = store; }
public IsolatedStorageLock(System.IO.IsolatedStorage.IsolatedStorageFile dir, string name) { _dir = dir; _name = name; }
void RecursiveDirectoryDelete(Storage storage, string path) { if (path.Length > 0) path += "/"; foreach (var subDirectory in storage.GetDirectoryNames(path + "*")) { RecursiveDirectoryDelete(storage, path + subDirectory); } DeleteFiles(storage, path); storage.DeleteDirectory(path); }