Remove() public method

public Remove ( ) : void
return void
Esempio n. 1
0
 public void DeleteFile_ThrowsIsolatedStorageException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <IsolatedStorageException>(() => isf.DeleteFile("foo"));
     }
 }
 public void MoveFile_Deleted_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.MoveFile("foo", "bar"));
     }
 }
Esempio n. 3
0
 public void DeleteRemovedDirectory_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.DeleteDirectory("foo"));
     }
 }
Esempio n. 4
0
 public void GetLastAccessTime_Removed_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.GetLastAccessTime("foo"));
     }
 }
Esempio n. 5
0
 public void CreateRemovedFile_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.CreateFile("foo"));
     }
 }
Esempio n. 6
0
 public void CreateDirectory_ThrowsIsolatedStorageException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <IsolatedStorageException>(() => isf.CreateDirectory("foo"));
     }
 }
Esempio n. 7
0
 public void OpenFile_Deleted_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.OpenFile("foo", FileMode.Create));
         Assert.Throws <InvalidOperationException>(() => isf.OpenFile("foo", FileMode.Create, FileAccess.ReadWrite));
         Assert.Throws <InvalidOperationException>(() => isf.OpenFile("foo", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite));
     }
 }
Esempio n. 8
0
        // Remove all stores of a particular type.
        public static void Remove(IsolatedStorageScope scope)
        {
            IsolatedStorageFile file = GetStore(scope);

            try
            {
                file.Remove();
            }
            finally
            {
                file.Close();
            }
        }
Esempio n. 9
0
        [System.Security.SecurityCritical] // auto-generated
        #endif
        public void Remove()
        {
#if !FEATURE_LEGACYNETCF
            bool     removedAll = true;
            FileLock groupLock  = FileLock.GetFileLock(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_LockPathPrefix), IsolatedStorageFile.s_GroupPathPrefix + "-" + m_ObfuscatedId);

            try {
                groupLock.Lock();

                foreach (string storeDir in Directory.UnsafeGetDirectories(Path.Combine(IsolatedStorageFile.IsolatedStorageRoot, IsolatedStorageFile.s_StorePathPrefix), "*", SearchOption.TopDirectoryOnly))
                {
                    string groupFile = Path.Combine(storeDir, IsolatedStorageFile.s_GroupFileName);

                    if (m_ObfuscatedId.Equals(File.UnsafeReadAllText(groupFile)))
                    {
                        IsolatedStorageFile f = IsolatedStorageFile.GetUserStoreFromGroupAndStorePath(Group, storeDir);
                        removedAll = removedAll & f.TryRemove();
                    }
                }

                IsolatedStorageFile.TouchFile(Path.Combine(m_GroupPath, IsolatedStorageFile.s_CleanupFileName));

                if (removedAll)
                {
                    IsolatedStorageAccountingInfo.RemoveAccountingInfo(m_GroupPath);
                    File.UnsafeDelete(Path.Combine(m_GroupPath, IsolatedStorageFile.s_IdFileName));
                    File.UnsafeDelete(Path.Combine(m_GroupPath, IsolatedStorageFile.s_CleanupFileName));
                    Directory.UnsafeDelete(m_GroupPath, false);
                }
            } catch (IOException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (UnauthorizedAccessException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } finally {
                groupLock.Unlock();
            }
#else // !FEATURE_LEGACYNETCF
            try {
                using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) {
                    isf.Remove();
                }
            } catch (IOException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            } catch (UnauthorizedAccessException) {
                // There isn't anything we can really do about this.  Ignoring these sorts of issues shouldn't lead to corruption.
            }
#endif // !FEATURE_LEGACYNETCF
        }
Esempio n. 10
0
 internal static void ClearSlFiles(string rFileName)
 {
     System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
     if (rFileName == null || rFileName.TrimEnd() == "")
     {
         isf.Remove();
     }
     else
     {
         if (isf.FileExists(rFileName))
         {
             isf.DeleteFile(rFileName);
         }
     }
     isf.Dispose();
 }
Esempio n. 11
0
		// use the caller stack to execute some write operations
		private void Write (IsolatedStorageFile isf)
		{
			isf.CreateDirectory ("testdir");

			string filename = Path.Combine ("testdir", "file");
			using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream (filename, FileMode.Create, isf)) {
			}
			isf.DeleteFile (filename);

			isf.DeleteDirectory ("testdir");
			try {
				isf.Remove ();
			}
			catch (IsolatedStorageException) {
				// fx 1.x doesn't like removing when things "could" still be in use
			}
		}