當前位置: 首頁>>代碼示例>>C#>>正文


C# IsolatedStorageFile.DeleteDirectory方法代碼示例

本文整理匯總了C#中System.IO.IsolatedStorage.IsolatedStorageFile.DeleteDirectory方法的典型用法代碼示例。如果您正苦於以下問題:C# IsolatedStorageFile.DeleteDirectory方法的具體用法?C# IsolatedStorageFile.DeleteDirectory怎麽用?C# IsolatedStorageFile.DeleteDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.IO.IsolatedStorage.IsolatedStorageFile的用法示例。


在下文中一共展示了IsolatedStorageFile.DeleteDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeleteDirectoryTree

        /// <summary>
        /// Deletes all of the folders and their contents in a given file-path.
        /// </summary>
        /// <param name="filepath">A valid filepath in IsolatedStorage.</param>
        /// <param name="storage">A reference to a valid IsolateStorageFile object.</param>
        public static void DeleteDirectoryTree(string filepath, IsolatedStorageFile storage)
        {
            //Bail if we don't detect any folders
            if (!HasDirectories(filepath)) return;

            //Get the root folder from the path
            var folderPath = GetRootDirectory(filepath);

            //Delete the root directory and have it cascade down
            storage.DeleteDirectory(folderPath);
        }
開發者ID:Aaronontheweb,項目名稱:isolatedstorage-extensions,代碼行數:16,代碼來源:IsolatedStorageHelper.Directory.cs

示例2: InnerClear

 private void InnerClear(IsolatedStorageFile iso, string path) {
     var fs = iso.GetFileNames(string.Format("{0}/*", path));
     foreach (var f in fs) {
         iso.DeleteFile(Path.Combine(path, f));
     }
     var ds = iso.GetDirectoryNames(string.Format("{0}/*", path));
     foreach (var d in ds) {
         var sp = Path.Combine(path, d);
         this.InnerClear(iso, sp);
         iso.DeleteDirectory(sp);
     }
 }
開發者ID:gruan01,項目名稱:Discuz.Mobi,代碼行數:12,代碼來源:Storage.cs

示例3: RecursiveDeleteDirectory

        public static void RecursiveDeleteDirectory(string directory, IsolatedStorageFile store)
        {
            foreach (var fileName in store.GetFileNames(directory + "\\*"))
            {
                store.DeleteFile(directory + "\\" + fileName);
            }

            foreach (var directoryName in store.GetDirectoryNames(directory + "\\*"))
            {
                RecursiveDeleteDirectory(directory + "\\" + directoryName, store);
            }

            store.DeleteDirectory(directory);
        }
開發者ID:bgourlie,項目名稱:petroledger,代碼行數:14,代碼來源:Util.cs

示例4: DeleteDirectory

 /// <summary>
 /// �ڴ洢����ɾ��Ŀ¼
 /// </summary>
 /// <param name="storage"></param>
 /// <param name="dirName"></param>
 public static void DeleteDirectory(IsolatedStorageFile storage, string dirName)
 {
     try
     {
         if (!string.IsNullOrEmpty(dirName) && storage.GetDirectoryNames(dirName).Length > 0)
         {
             storage.DeleteDirectory(dirName);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("�޷��ڴ洢����ɾ��Ŀ¼.", ex);
     }
 }
開發者ID:Andy-Yin,項目名稱:MY_OA_RM,代碼行數:19,代碼來源:IsolatedStorageHelper.cs

示例5: DeleteDirectoryRecursively

 public static void DeleteDirectoryRecursively(IsolatedStorageFile storageFile, string directoryName)
 {
     var pattern = directoryName + @"\*";
     var files = storageFile.GetFileNames(pattern);
     foreach (var fileName in files)
     {
         storageFile.DeleteFile(Path.Combine(directoryName, fileName));
     }
     var dirs = storageFile.GetDirectoryNames(pattern);
     foreach (var dirName in dirs)
     {
         DeleteDirectoryRecursively(storageFile, Path.Combine(directoryName, dirName));
     }
     storageFile.DeleteDirectory(directoryName);
 }
開發者ID:Korshunoved,項目名稱:Win10reader,代碼行數:15,代碼來源:CredentialsProvider.cs

示例6: Write

		// 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
			}
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:18,代碼來源:IsolatedStorageFileCas.cs

示例7: DeleteDirectory

        public static void DeleteDirectory(IsolatedStorageFile store, String root)
        {
            String dir = root;

            //  delete file in current dir
            foreach (String file in store.GetFileNames(dir + "/*"))
            {
                store.DeleteFile(dir + "/" + file);
            }

            //  delete sub-dir
            foreach (String subdir in store.GetDirectoryNames(dir + "/*"))
            {
                DeleteDirectory(store, dir + "/" + subdir + "/");
            }

            //  delete current dir
            store.DeleteDirectory(dir);
        }
開發者ID:GhostSoar,項目名稱:JigsawPuzzle,代碼行數:19,代碼來源:ChoosePictures.xaml.cs

示例8: DeleteDirectory

        private void DeleteDirectory(string path, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(path))
            return;

              var folders = iso.GetDirectoryNames(path + "/" + "*.*");

              foreach (var folder in folders)
              {
            string folderPath = path + "/" + folder;
            DeleteDirectory(folderPath, iso);
              }

              foreach (var file in iso.GetFileNames(path + "/" + "*.*"))
              {
            iso.DeleteFile(path + "/" + file);
              }

              if (path != "")
            iso.DeleteDirectory(path);
        }
開發者ID:msachs,項目名稱:TestRepo2,代碼行數:21,代碼來源:StoragePhone7.cs

示例9: DeleteDirectory

 // Can't delete unless empty. Must recursively delete files and folders
 private static void DeleteDirectory(IsolatedStorageFile storage, string dir)
 {
     foreach (var file in storage.GetFileNames(Path.Combine(dir, "*")))
     {
         storage.DeleteFile(Path.Combine(dir, file));
     }
     foreach (var subDir in storage.GetDirectoryNames(Path.Combine(dir, "*")))
     {
         DeleteDirectory(storage, Path.Combine(dir, subDir));
     }
     storage.DeleteDirectory(dir);
 }
開發者ID:achingono,項目名稱:WinPhoneGmail,代碼行數:13,代碼來源:MailStorage.cs

示例10: DeleteDirectoryRecursively

 // helper function from: http://stackoverflow.com/questions/18422331/easy-way-to-recursively-delete-directories-in-isolatedstorage-on-wp7-8
 private void DeleteDirectoryRecursively(IsolatedStorageFile storageFile, String dirName)
 {
     try
     {
         String pattern = dirName + @"\*";
         String[] files = storageFile.GetFileNames(pattern);
         foreach (var fName in files)
         {
             storageFile.DeleteFile(Path.Combine(dirName, fName));
         }
         String[] dirs = storageFile.GetDirectoryNames(pattern);
         foreach (var dName in dirs)
         {
             DeleteDirectoryRecursively(storageFile, Path.Combine(dirName, dName));
         }
         if (storageFile.DirectoryExists(dirName))
         {
             storageFile.DeleteDirectory(dirName);
         }
     }
     catch(Exception e)
     {
         Debug.WriteLine("Unable to delete directory : " + dirName);
     }
 }
開發者ID:stevengill,項目名稱:phonegap-app-developer,代碼行數:26,代碼來源:Unzip.cs

示例11: DeleteFileHelper

        private static void DeleteFileHelper(IsolatedStorageFile isoStore, string path)
        {
            int retries = 3;

            while (retries-- > 0)
            {
                try
                {
                    if (isoStore.FileExists(path))
                    {
                        isoStore.DeleteFile(path);

                        try
                        {
                            isoStore.DeleteDirectory(Path.GetDirectoryName(path));
                        }
                        catch (IsolatedStorageException)
                        {
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                catch (IsolatedStorageException)
                {
                    // random iso-store failures..
                    //
                    Thread.Sleep(50);
                }
                return;
            }
        }
開發者ID:Kinnara,項目名稱:AgFx,代碼行數:34,代碼來源:IsoStoreProvider.cs

示例12: DeleteAllFiles

        private static void DeleteAllFiles(IsolatedStorageFile isf)
        {
            if (false == isf.DirectoryExists(Constants.MyScriptsDirectoryName))
                return;

            var filesDel = isf.GetFileNames(string.Format("{0}\\*", Constants.MyScriptsDirectoryName));
            foreach (var f in filesDel)
            {
                isf.DeleteFile(Constants.MyScriptsDirectoryName + "\\" + f);
            }
            isf.DeleteDirectory(Constants.MyScriptsDirectoryName);
        }
開發者ID:slodge,項目名稱:main,代碼行數:12,代碼來源:MainViewModel.cs

示例13: MoveOldCrashlogsIfNeeded

 public void MoveOldCrashlogsIfNeeded(IsolatedStorageFile store)
 {
     try
     {
         if (store.DirectoryExists(Constants.OldCrashDirectoryName))
         {
             var files = store.GetFileNames(Path.Combine(Constants.OldCrashDirectoryName, Constants.CrashFilePrefix + "*.log"));
             if (files.Length > 0)
             {
                 if (!store.DirectoryExists(Constants.CrashDirectoryName))
                 {
                     store.CreateDirectory(Constants.CrashDirectoryName);
                 }
                 foreach (var fileName in files)
                 {
                     store.MoveFile(Path.Combine(Constants.OldCrashDirectoryName, Path.GetFileName(fileName)), Path.Combine(Constants.CrashDirectoryName, Path.GetFileName(fileName)));
                 }
                 if (store.GetFileNames(Path.Combine(Constants.OldCrashDirectoryName, Constants.CrashFilePrefix + "*.*")).Length == 0)
                 {
                     store.DeleteDirectory(Constants.OldCrashDirectoryName);
                 }
             }
         }
     }
     catch (Exception e)
     {
         HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e);
     }
 }
開發者ID:bitstadium,項目名稱:HockeySDK-Windows,代碼行數:29,代碼來源:CrashHandler.cs

示例14: DeleteRecursive

        private static void DeleteRecursive(Path dir, IsolatedStorageFile isf)
        {
            // Delete every subdirectory's contents recursively
            foreach (string subDir in isf.GetDirectoryNames(dir.PathString + "/*"))
                DeleteRecursive(dir.NavigateIn(subDir), isf);
            // Delete every file inside
            foreach (string file in isf.GetFileNames(dir.PathString + "/*"))
                isf.DeleteFile(System.IO.Path.Combine(dir.PathString, file));

            isf.DeleteDirectory(dir.PathString);
        }
開發者ID:hmehart,項目名稱:Notepad,代碼行數:11,代碼來源:Directory.cs

示例15: DeleteDirectoryRecursive

 public void DeleteDirectoryRecursive(IsolatedStorageFile isolatedStorageFile, String dirName)
 {
     String pattern = dirName + @"\*";
     String[] files = isolatedStorageFile.GetFileNames(pattern);
     foreach (String fName in files)
     {
         isolatedStorageFile.DeleteFile(Path.Combine(dirName, fName));
     }
     String[] dirs = isolatedStorageFile.GetDirectoryNames(pattern);
     foreach (String dName in dirs)
     {
         DeleteDirectoryRecursive(isolatedStorageFile, Path.Combine(dirName, dName));
     }
     isolatedStorageFile.DeleteDirectory(dirName);
 }
開發者ID:joshgo,項目名稱:NLog,代碼行數:15,代碼來源:IsolatedStorageFileTargetTests.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFile.DeleteDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。