Remove() public method

public Remove ( ) : void
return void
Exemplo 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"));
     }
 }
Exemplo n.º 3
0
 public void DeleteRemovedDirectory_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.DeleteDirectory("foo"));
     }
 }
Exemplo n.º 4
0
 public void GetLastAccessTime_Removed_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.GetLastAccessTime("foo"));
     }
 }
Exemplo n.º 5
0
 public void CreateRemovedFile_ThrowsInvalidOperationException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <InvalidOperationException>(() => isf.CreateFile("foo"));
     }
 }
Exemplo n.º 6
0
 public void CreateDirectory_ThrowsIsolatedStorageException()
 {
     using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly())
     {
         isf.Remove();
         Assert.Throws <IsolatedStorageException>(() => isf.CreateDirectory("foo"));
     }
 }
Exemplo 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));
     }
 }
Exemplo 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();
            }
        }
Exemplo 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
        }
Exemplo 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();
 }
Exemplo 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
			}
		}