public void Remove(string key) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if (isf.FileExists(GetFileName(key))) { isf.DeleteFile(key); } } }
private static void Email_Delete_File(IsolatedStorageFile store) { try { store.DeleteFile(filename); } catch (Exception) { } }
public void Recycle() { foreach (string file in m_FilesPendingRecycle) { m_IsolatedStorageFile.DeleteFile(file); m_FileNamesMap.Remove(file); } m_FilesPendingRecycle.Clear(); m_FilesToAddToStorageQueue = new ConcurrentQueue <string>(); }
private static void SafeDeleteFile(IsolatedStorageFile store) { try { store.DeleteFile(filename); } catch (Exception) { } }
/// <summary> /// Removes the user token from the phone store, so on the next call to AuthenticateUser the Loginscreen is shown. /// Effectively this serves as a logout from your app. In most cases you want to call AuthenticateUser() immediatley after RemoveUserToken /// </summary> public void RemoveUserToken() { IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication(); var filename = Constants.AuthStatusKey + ".crypt"; if (file.FileExists(filename)) { file.DeleteFile(filename); } }
public void ClearCache() { IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForApplication(); string stateFile = Path.Combine(ReceiptStore, "state.xml"); if (userStore.FileExists(stateFile)) { userStore.DeleteFile(stateFile); } }
private static void SafeDeleteFile(IsolatedStorageFile store) { try { store.DeleteFile(Filename); } catch (Exception) { } }
protected void Clean() { AspectF.Define. WriteLock(m_QueueLock). IgnoreExceptions(). Do(() => { string[] directoryNames = m_Store.GetDirectoryNames(NCrawlerQueueDirectoryName + "\\*"); string workFolderName = WorkFolderPath.Split('\\').Last(); if (directoryNames.Where(w => w == workFolderName).Any()) { m_Store. GetFileNames(Path.Combine(WorkFolderPath, "*")). ForEach(f => m_Store.DeleteFile(Path.Combine(WorkFolderPath, f))); m_Store.DeleteDirectory(WorkFolderPath); } }); Initialize(); }
private void RemoveItem(string itemLocation) { string[] files = store.GetFileNames(GenerateSearchString(itemLocation)); foreach (string fileName in files) { string fileToDelete = Path.Combine(itemLocation, fileName); store.DeleteFile(fileToDelete); } store.DeleteDirectory(itemLocation); }
/// <summary> /// Removes all state from the store. /// </summary> public void Clear() { IsolatedStorageFile store = IsolatedStorageFile.GetStore(scope, null, null); string[] files = store.GetFileNames("*"); foreach (string file in files) { store.DeleteFile(file); } }
public void CreateFile() { IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); Assert.Throws <ArgumentNullException> (delegate { isf.CreateFile(null); }, "null"); Assert.Throws <ArgumentException> (delegate { isf.CreateFile(String.Empty); }, "Empty"); try { isf.DeleteFile("create-file"); } catch (IsolatedStorageException) { // ignore this exception here since // it's generated when the file // doesn't exist. } // now test the above behavior just to make sure Assert.Throws(delegate { isf.DeleteFile("create-file"); }, typeof(IsolatedStorageException)); Assert.IsFalse(isf.FileExists("create-file"), "before"); IsolatedStorageFileStream fs = isf.CreateFile("create-file"); try { Assert.IsTrue(isf.FileExists("create-file"), "after"); Assert.Throws(delegate { isf.CreateFile(null); }, typeof(ArgumentNullException), "null"); Assert.Throws(delegate { isf.CreateFile(String.Empty); }, typeof(ArgumentException), "empty"); Assert.Throws(delegate { isf.CreateFile("does-not-exist/new"); }, typeof(IsolatedStorageException), "subdir does not exist"); } finally { fs.Close(); isf.DeleteFile("create-file"); Assert.IsFalse(isf.FileExists("create-file"), "deleted"); } isf.Remove(); Assert.Throws(delegate { isf.CreateFile(null); }, typeof(IsolatedStorageException), "Remove"); isf.Dispose(); Assert.Throws(delegate { isf.CreateFile(null); }, typeof(ObjectDisposedException), "Dispose"); }
public void deleteData(string filename) { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (storage.FileExists(filename)) { storage.DeleteFile(filename); } } }
/// <summary> /// clean log /// </summary> public static void CleanLog() { using (IsolatedStorageFile logstore = IsolatedStorageFile.GetUserStoreForApplication()) { if (logstore.FileExists("logstore\\Log.txt")) { logstore.DeleteFile("logstore\\Log.txt"); } } }
public override void DeleteFile(string path) { IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); if (!store.FileExists(path)) { return; } store.DeleteFile(path); }
private static void SafeDeleteFile(IsolatedStorageFile store) { try { store.DeleteFile(filename); } catch { } }
/// <summary> /// Deletes the master key file from storage /// </summary> public static void DeleteMasterKey() { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForAssembly()) { if (store.FileExists(KeyFileName)) { store.DeleteFile(KeyFileName); } } }
private static void SafeDeleteFile(IsolatedStorageFile store, string fileName) { try { store.DeleteFile(_fileName); } catch (Exception) { } }
/// <summary> /// Removes an object /// </summary> /// <param name="key"></param> public static void RemoveObjectFromIsolated(string key) { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (storage.FileExists(key)) { storage.DeleteFile(key); } } }
/// <summary> /// Deletes the specified file from storage. /// throws IsolatedStorageException /// </summary> /// <param name="file"></param> internal static void DeleteFile(string file) { using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (storage.FileExists(file)) { storage.DeleteFile(file); } } }
public void deleteUserDetails() { using (IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication()) { if (isoStorage.FileExists("userDetails.xml")) { isoStorage.DeleteFile("userDetails.xml"); } } }
/// <summary> /// 清空独立存储 /// </summary> /// <param name="fileName"></param> public static void ReMove(string fileName) { using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { if (isf.FileExists(fileName)) { isf.DeleteFile(fileName); } } }
/// <summary> /// Writes text to log file located in isolated storage. /// Clears log file if it's older than CleanupInterval /// </summary> /// <param name="text">Text to be written in the log file.</param> private static void WriteToFile(string text) { // http://stackoverflow.com/questions/15456986/how-to-gracefully-get-out-of-abandonedmutexexception // "if you can assure the integrity of the data structures protected by the mutex you can simply ignore the exception and continue executing your application normally." // The bg agent can terminate and the mutex is not released properly try { Lock.WaitOne(); } catch (AbandonedMutexException e) { FSLog.Exception(e); } catch (Exception e) { FSLog.Exception(e); } try { IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); if (storage.FileExists(LogFile)) { if ((DateTime.Now.Ticks - CleanupInterval) > storage.GetLastWriteTime(LogFile).Ticks) { storage.DeleteFile(LogFile); } } IsolatedStorageFileStream isoStream = null; try { isoStream = new IsolatedStorageFileStream(LogFile, FileMode.Append, FileAccess.Write, FileShare.Write, IsolatedStorageFile.GetUserStoreForApplication()); using (StreamWriter logFile = new StreamWriter(isoStream)) { isoStream = null; logFile.WriteLine(text); logFile.Flush(); } } finally { if (isoStream != null) { isoStream.Dispose(); } } } finally { Lock.ReleaseMutex(); } }
static public async System.Threading.Tasks.Task <List <string> > UploadFilesAsync(DriveService driveService) { List <string> UploadListFileId = new List <string>(); IsolatedStorageFile machine = IsolatedStorageFile.GetMachineStoreForAssembly(); long epochTicks = new DateTime(1970, 1, 1).Ticks; long unixTime = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond); string ZipFileName = $"package_{unixTime}.zip"; string idGoogleFile = ""; using (IsolatedStorageFileStream fsZip = new IsolatedStorageFileStream(ZipFileName, FileMode.Create, machine)) { using (ZipOutputStream s = new ZipOutputStream(fsZip)) { while (ListIsoStorageFile.ListFile.Count > 0) { string nameFile = ListIsoStorageFile.Get(); if (nameFile.EndsWith(".zip")) { idGoogleFile = await SendFile(driveService, machine, nameFile); UploadListFileId.Add($"{nameFile} ({idGoogleFile})"); Cliest.eventLog.WriteEntry($"Resend {nameFile} ({idGoogleFile})", EventLogEntryType.Warning, 786); continue; } try { IsolatedStorageFileStream stream = new IsolatedStorageFileStream(nameFile, FileMode.Open, machine); s.PutNextEntry(nameFile); byte[] buffer = ReadToEnd(stream); s.Write(buffer, 0, buffer.Length); stream.Close(); UploadListFileId.Add(nameFile); machine.DeleteFile(nameFile); } catch (Exception ex) { Cliest.eventLog.WriteEntry($"{ex.Message} ({nameFile}), count: {ListIsoStorageFile.ListFile.Count}", EventLogEntryType.Error, 781); ListIsoStorageFile.Add(nameFile); } } } } idGoogleFile = await SendFile(driveService, machine, ZipFileName); UploadListFileId.Add(idGoogleFile); return(UploadListFileId); }
private void ProcessTransfer(BackgroundTransferRequest transfer) { switch (transfer.TransferStatus) { case TransferStatus.Completed: // If the status code of a completed transfer is 200 or 206, the // transfer was successful if (transfer.StatusCode == 200 || transfer.StatusCode == 206) { // Remove the transfer request in order to make room in the // queue for more transfers. Transfers are not automatically // removed by the system. RemoveTransferRequest(transfer.RequestId); string filename = transfer.Tag.Substring(transfer.Tag.LastIndexOf("#") + 1); // In this example, the downloaded file is moved into the root // Isolated Storage directory using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { if (isoStore.FileExists(filename)) { isoStore.DeleteFile(filename); } isoStore.MoveFile(transfer.DownloadLocation.OriginalString, filename); } App.player.selectedBook.addFile(filename, true); } else { // This is where you can handle whatever error is indicated by the // StatusCode and then remove the transfer from the queue. RemoveTransferRequest(transfer.RequestId); if (transfer.TransferError != null) { // Handle TransferError if one exists. } } break; case TransferStatus.WaitingForExternalPowerDueToBatterySaverMode: WaitingForExternalPowerDueToBatterySaverMode = true; break; case TransferStatus.WaitingForWiFi: WaitingForWiFi = true; break; } }
private static void DeleteFolder(string bookId) { try { using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication()) { string path = ModelExtensions.GetBookCoverPath(bookId); if (file.FileExists(path)) { file.DeleteFile(path); } string coverPath = ModelExtensions.GetBookFullCoverPath(bookId); if (file.FileExists(coverPath)) { file.DeleteFile(coverPath); } if (file.DirectoryExists(bookId)) { string[] fileNames = file.GetFileNames(bookId + @"\*.*"); bool flag = false; foreach (string fileName in fileNames) { try { file.DeleteFile(Path.Combine(bookId, fileName)); } catch (Exception) { flag = true; } } if (!flag) { file.DeleteDirectory(bookId); } } } } catch (Exception) { } }
private static void Upgrade(IsolatedStorageFile store) { var files = new List <string>( store.GetFileNames()); if (!files.Contains("Database.kdbx")) { return; } var appSettings = IsolatedStorageSettings .ApplicationSettings; string url; if (!appSettings.TryGetValue("Url", out url)) { url = null; } var info = new DatabaseInfo(); using (var fs = store.OpenFile("Database.kdbx", FileMode.Open)) { var source = string.IsNullOrEmpty(url) ? "7Pass" : DatabaseUpdater.WEB_UPDATER; var details = new DatabaseDetails { Url = url, Source = source, Type = SourceTypes.OneTime, Name = "7Pass 1.x database", }; info.SetDatabase(fs, details); } store.DeleteFile("Database.kdbx"); store.DeleteFile("Protection.bin"); store.DeleteFile("Decrypted.xml"); }
private void removeCache() { if (store.FileExists(midfile)) { store.DeleteFile(midfile); Dispatcher.BeginInvoke(() => { TrackTime.Text = "ÒÑÇå³ý»º´æ..."; }); } }
/// <summary> /// Reads the game state from a file and continues the game from where /// it was left. /// </summary> private void RestoreState() { IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); if (!store.FileExists(gameStateFile)) { return; } int emptyCells = 0; using (IsolatedStorageFileStream stream = store.OpenFile(gameStateFile, FileMode.Open)) { using (BinaryReader reader = new BinaryReader(stream)) { // Read the state and stats gameState = (GameState)reader.ReadInt32(); game.PlayerMoves = reader.ReadInt32(); gameTimeElapsed = new TimeSpan(reader.ReadInt64()); gameStartTime = DateTime.Now - gameTimeElapsed; // Read contents of the cells for (int row = 0; row < GameLogic.RowLength; row++) { for (int col = 0; col < GameLogic.ColumnLength; col++) { int value = reader.ReadInt32(); game.Model.BoardNumbers[row][col].Value = value; game.Model.BoardNumbers[row][col].SetByGame = reader.ReadBoolean(); if (value == 0) { emptyCells++; } } } } } store.DeleteFile(gameStateFile); if (gameState == GameState.Ongoing) { game.EmptyCells = emptyCells; gameTimer.Start(); } else { game.EmptyCells = 0; } DataContext = game.Model; UpdateStatus(); }
public static void deleteFilesInFolder(String path) { using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication()) { string[] arFiles = isoStore.GetFileNames(CFilePath.join(path, "*")); foreach (string strFile in arFiles) { isoStore.DeleteFile(CFilePath.join(path, strFile)); } } }
public static void DeleteFile(string fileName) { #if OPENSILVER || SILVERLIGHT using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication()) #else using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForAssembly()) #endif { storage.DeleteFile(fileName); } }
public void DeleteData(string path) { IsolatedStorageFile isoStore = getStore(); string filePath = getPath(path); if (isoStore.FileExists(filePath)) { isoStore.DeleteFile(filePath); } }