本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}