示例#1
0
        public void MultiLevel()
        {
            // see bug #4101
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly();

            try {
                isf.CreateDirectory("dir1");
                string [] dirs = isf.GetDirectoryNames("*");
                Assert.AreEqual(dirs.Length, 1, "1a");
                Assert.AreEqual(dirs [0], "dir1", "1b");

                isf.CreateDirectory("dir1/test");
                dirs = isf.GetDirectoryNames("dir1/*");
                Assert.AreEqual(dirs.Length, 1, "2a");
                Assert.AreEqual(dirs [0], "test", "2b");

                isf.CreateDirectory("dir1/test/test2a");
                isf.CreateDirectory("dir1/test/test2b");
                dirs = isf.GetDirectoryNames("dir1/test/*");
                Assert.AreEqual(dirs.Length, 2, "3a");
                Assert.AreEqual(dirs [0], "test2a", "3b");
                Assert.AreEqual(dirs [1], "test2b", "3c");
            }
            finally {
                isf.DeleteDirectory("dir1/test/test2a");
                isf.DeleteDirectory("dir1/test/test2b");
                isf.DeleteDirectory("dir1/test");
                isf.DeleteDirectory("dir1");
            }
        }
        // Add dir/file recursively
        void AddFileToDirectory(IsoDirectory dir, IsolatedStorageFile isf)
        {
            string[] childrendir, childrenfile;
            if (string.IsNullOrEmpty(dir.FilePath))
            {
                childrendir  = isf.GetDirectoryNames();
                childrenfile = isf.GetFileNames();
            }
            else
            {
                childrendir  = isf.GetDirectoryNames(dir.FilePath + "/");
                childrenfile = isf.GetFileNames(dir.FilePath + "/");
            }

            // Add directory entity
            foreach (var dirname in childrendir)
            {
                var childdir = new IsoDirectory(dirname, dir.FilePath + "/" + dirname);
                AddFileToDirectory(childdir, isf);
                dir.Children.Add(childdir);
            }

            // Add file entity
            foreach (var filename in childrenfile)
            {
                dir.Children.Add(new IsoFile(filename, dir.FilePath + "/" + filename));
            }
        }
示例#3
0
        private static int countDirsNumber(IsolatedStorageFile isf, string strPath)
        {
            int length = isf.GetDirectoryNames(strPath + "/*").Length;

            foreach (string str in isf.GetDirectoryNames(strPath + "/*"))
            {
                length += countDirsNumber(isf, strPath + "/" + str);
            }
            return(length);
        }
		[Test] // https://bugzilla.novell.com/show_bug.cgi?id=376188
		public void CreateSubDirectory ()
		{
			IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly ();
			isf.CreateDirectory ("subdir");
			isf.CreateDirectory ("subdir/subdir2");
			Assert.AreEqual (1, isf.GetDirectoryNames ("*").Length, "subdir");
			Assert.AreEqual (1, isf.GetDirectoryNames ("subdir/*").Length, "subdir/subdir2");
			isf.DeleteDirectory ("subdir/subdir2");
			isf.DeleteDirectory ("subdir");
		}
示例#5
0
 public string[] GetDirectorys(string p_SearchPattern)
 {
     if (string.IsNullOrEmpty(p_SearchPattern))
     {
         return(StorageFileManage.GetDirectoryNames());
     }
     else
     {
         return(StorageFileManage.GetDirectoryNames(p_SearchPattern));
     }
 }
示例#6
0
 public void PurgeOldSessions()
 {
     string[] otherSessionKeys = _storage.GetDirectoryNames("ECollegeCache\\*");
     foreach (string otherSessionKey in otherSessionKeys)
     {
         if (!_sessionKey.Equals(otherSessionKey))
         {
             RecursiveDeleteDirectory(string.Format("ECollegeCache\\{0}", otherSessionKey));
         }
     }
 }
 /// <summary>
 /// Removes all items from this Isolated Storage area.
 /// </summary>
 public override void Flush()
 {
     lock (store)
     {
         string[] directories = store.GetDirectoryNames(GenerateSearchString(storageAreaName));
         foreach (string itemLocation in directories)
         {
             string itemRoot = GenerateItemLocation(itemLocation);
             RemoveItem(itemRoot);
         }
     }
 }
        public void ReadDirectoryAsFile()
        {
            string dirname          = "this-is-a-dir";
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForDomain();

            try {
                string[] dirs = isf.GetDirectoryNames(dirname);
                if (dirs.Length == 0)
                {
                    isf.CreateDirectory(dirname);
                }
                Read(dirname);
            }
            catch (UnauthorizedAccessException uae) {
                // check that we do not leak the full path to the missing file
                // as we do not have the FileIOPermission's PathDiscovery rights
                Assert.IsTrue(uae.Message.IndexOf(dirname) >= 0, "dirname");
                Assert.IsFalse(uae.Message.IndexOf("\\" + dirname) >= 0, "fullpath");
                try {
                    isf.DeleteDirectory(dirname);
                }
                catch (IsolatedStorageException) {
                    // this isn't where we want ot fail!
                    // and 1.x isn't always cooperative
                }
                throw;
            }
        }
示例#9
0
        public static String[] GetAllDirectories(String pattern, IsolatedStorageFile store)
        {
            // obtain all the subfolders under the specified folder
            string root = System.IO.Path.GetDirectoryName(pattern);

            if (root != "")
            {
                root += "/";
            }
            //get all folders
            string[] directories;
            directories = store.GetDirectoryNames(pattern);
            List <string> directoryList = new List <string>(directories);

            //get matched folders
            for (int i = 0, max = directories.Length; i < max; i++)
            {
                string   directory = directoryList[i] + "/";
                string[] more      = GetAllDirectories(root + directory + "*", store);
                //iterate through each folder and add current path
                for (int j = 0; j < more.Length; j++)
                {
                    more[j] = directory + more[j];
                }
                // add the found folders into the array
                foreach (string sub in more)
                {
                    directoryList.Insert(i + 1, sub);
                }
                i   += more.Length;
                max += more.Length;
            }
            return((string[])directoryList.ToArray());
        }
示例#10
0
        /// <summary>
        /// Copies a source directory to specified destination directory.
        /// </summary>
        /// <param name="src">Path of the source directory</param>
        /// <param name="dest">Path of the destination directory</param>
        internal static void CopyDirectory(string src, string dest)
        {
            using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!storage.DirectoryExists(dest))
                {
                    storage.CreateDirectory(dest);
                }

                // Copy all files.
                string[] files = storage.GetFileNames(src + "\\*.*");
                foreach (string file in files)
                {
                    string srcfile  = Path.Combine(src, file);
                    string destfile = Path.Combine(dest, file);
                    // Delete file if exists
                    if (storage.FileExists(destfile))
                    {
                        storage.DeleteFile(destfile);
                    }
                    storage.CopyFile(srcfile, destfile);
                }

                // Process subdirectories.
                string[] dirs = storage.GetDirectoryNames(src + "\\*");
                foreach (string dir in dirs)
                {
                    string destinationDir = Path.Combine(dest, dir);
                    string srcDir         = Path.Combine(src, dir);
                    CopyDirectory(srcDir, destinationDir);
                }
            }
        }
示例#11
0
        void IsoFileExplorer_Loaded(object sender, RoutedEventArgs e)
        {
            isoFile = IsolatedStorageFile.GetUserStoreForApplication();
            string[] directories = isoFile.GetDirectoryNames();
            string[] files       = isoFile.GetFileNames();

            ListBoxItem itm;

            FileList.Items.Clear();
            foreach (string file in files)
            {
                if (file != "RecentPuzzles.xml")
                {
                    itm         = new ListBoxItem();
                    itm.Tag     = FileLocation.IsolatedStorage;
                    itm.Content = file;
                    FileList.Items.Add(itm);
                }
            }
            string[] embeddedResources = this.GetType().Assembly.GetManifestResourceNames();
            foreach (string item in embeddedResources)
            {
                string puzzlePrefix = "SilverSudoku.Puzzles";
                if (item.Contains(puzzlePrefix))
                {
                    itm         = new ListBoxItem();
                    itm.Tag     = FileLocation.Assembly;
                    itm.Content = item;
                    FileList.Items.Add(itm);
                }
            }
        }
示例#12
0
文件: File.cs 项目: trieu/phonegap
        private void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile)
        {
            string path = File.AddSlashToDirectory(sourceDir);

            if (!isoFile.DirectoryExists(destDir))
            {
                isoFile.CreateDirectory(destDir);
            }
            destDir = File.AddSlashToDirectory(destDir);
            string[] files = isoFile.GetFileNames(path + "*");
            if (files.Length > 0)
            {
                foreach (string file in files)
                {
                    isoFile.CopyFile(path + file, destDir + file);
                }
            }
            string[] dirs = isoFile.GetDirectoryNames(path + "*");
            if (dirs.Length > 0)
            {
                foreach (string dir in dirs)
                {
                    CopyDirectory(path + dir, destDir + dir, isoFile);
                }
            }
        }
示例#13
0
 public static bool emptyDir(string strPath)
 {
     if (!string.IsNullOrEmpty(strPath))
     {
         try
         {
             using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
             {
                 if (!file.DirectoryExists(strPath))
                 {
                     return(false);
                 }
                 foreach (string str in file.GetFileNames(strPath + "/*"))
                 {
                     file.DeleteFile(strPath + "/" + str);
                     Log.d("StorageIO", "delete file " + strPath + "/" + str);
                 }
                 foreach (string str2 in file.GetDirectoryNames(strPath + "/*"))
                 {
                     deleteDir(file, strPath + "/" + str2, true);
                     Log.d("StorageIO", "delete dir " + strPath + "/" + str2);
                 }
             }
             return(true);
         }
         catch (Exception exception)
         {
             Log.e("StorageIO", string.Concat(new object[] { "emptyDir clear path fail=", strPath, " \n", exception }));
         }
     }
     return(false);
 }
示例#14
0
 public static List <string> dirsDetail(string strPath)
 {
     if (!string.IsNullOrEmpty(strPath))
     {
         try
         {
             using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
             {
                 if (!file.DirectoryExists(strPath))
                 {
                     return(null);
                 }
                 List <string> list = new List <string>();
                 foreach (string str in file.GetDirectoryNames(strPath + "/*"))
                 {
                     list.Add(strPath + "/" + str);
                 }
                 return(list);
             }
         }
         catch (Exception exception)
         {
             Log.e("StorageIO", string.Concat(new object[] { "dirsDetail Exception=", strPath, " \n", exception }));
         }
     }
     return(null);
 }
示例#15
0
 public static void DeleteAllAttachmentData()
 {
     string[] attachmentPaths = new string[2];
     attachmentPaths[0] = HikeConstants.FILES_ATTACHMENT;
     attachmentPaths[1] = HikeConstants.FILES_BYTE_LOCATION;
     using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         foreach (string attachmentPath in attachmentPaths)
         {
             if (store.DirectoryExists(attachmentPath))
             {
                 string[] directoryNames = store.GetDirectoryNames(attachmentPath + "/*");
                 foreach (string directoryName in directoryNames)
                 {
                     string   escapedDirectoryName = directoryName.Replace(":", "_");
                     string[] fileNames            = store.GetFileNames(attachmentPath + "/" + escapedDirectoryName + "/*");
                     foreach (string fileName in fileNames)
                     {
                         store.DeleteFile(attachmentPath + "/" + escapedDirectoryName + "/" + fileName);
                     }
                 }
             }
         }
     }
 }
示例#16
0
    //</snippet2>
    //<snippet6>
    public void DeleteFiles()
    {
        //<snippet9>
        try
        {
            IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
                                                                       IsolatedStorageScope.Assembly |
                                                                       IsolatedStorageScope.Domain,
                                                                       typeof(System.Security.Policy.Url),
                                                                       typeof(System.Security.Policy.Url));

            String[] dirNames  = isoFile.GetDirectoryNames("*");
            String[] fileNames = isoFile.GetFileNames("*");
            //</snippet9>

            // List the files currently in this Isolated Storage.
            // The list represents all users who have personal
            // preferences stored for this application.
            if (fileNames.Length > 0)
            {
                for (int i = 0; i < fileNames.Length; ++i)
                {
                    // Delete the files.
                    isoFile.DeleteFile(fileNames[i]);
                }
                // Confirm that no files remain.
                fileNames = isoFile.GetFileNames("*");
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
    }
示例#17
0
    //</snippet4>
    //<snippet3>
    public bool GetIsoStoreInfo()
    {
        // Get a User store with type evidence for the current Domain and the Assembly.
        IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
                                                                   IsolatedStorageScope.Assembly |
                                                                   IsolatedStorageScope.Domain,
                                                                   typeof(System.Security.Policy.Url),
                                                                   typeof(System.Security.Policy.Url));

        String[] dirNames  = isoFile.GetDirectoryNames("*");
        String[] fileNames = isoFile.GetFileNames("*");

        // List directories currently in this Isolated Storage.
        if (dirNames.Length > 0)
        {
            for (int i = 0; i < dirNames.Length; ++i)
            {
                Console.WriteLine("Directory Name: " + dirNames[i]);
            }
        }

        // List the files currently in this Isolated Storage.
        // The list represents all users who have personal preferences stored for this application.
        if (fileNames.Length > 0)
        {
            for (int i = 0; i < fileNames.Length; ++i)
            {
                Console.WriteLine("File Name: " + fileNames[i]);
            }
        }

        isoFile.Close();
        return(true);
    }
示例#18
0
        //*******************************************************************************************
        //Enable this if you'd like to be able access the list from outside the class. All list
        //methods are commented out below and replaced with Debug.WriteLine.
        //Default implementation is to simply output the directories to the console (Debug.WriteLine)
        //so if it looks like nothing's happening, check the Output window :) - keyboardP

        // public static List<string> listDir = new List<string>();

        //********************************************************************************************

        //Use "*" as the pattern string in order to retrieve all files and directories
        public static void GetIsolatedStorageView(string pattern, IsolatedStorageFile storeFile)
        {
            string root = System.IO.Path.GetDirectoryName(pattern);

            if (root != "")
            {
                root += "/";
            }

            string[] directories = storeFile.GetDirectoryNames(pattern);
            //if the root directory has not FOLDERS, then the GetFiles() method won't be called.
            //the line below calls the GetFiles() method in this event so files are displayed
            //even if there are no folders
            //if (directories.Length == 0)
            GetFiles(root, "*", storeFile);


            for (int i = 0; i < directories.Length; i++)
            {
                string dir = directories[i] + "/";

                //Add this directory into the list
                // listDir.Add(root + directories[i]);

                //Write to output window
                Debug.WriteLine(root + directories[i]);


                //Get all the files from this directory
                GetFiles(root + directories[i], pattern, storeFile);

                //Continue to get the next directory
                GetIsolatedStorageView(root + dir + "*", storeFile);
            }
        }
示例#19
0
        public static void DeleteDirectory(string folderToRemove)
        {
            try
            {
                //get all folders inside it                Folder/*
                string[] folders = store.GetDirectoryNames(folderToRemove + "*");
                for (int i = 0; i < folders.Length; i++)
                {
                    DeleteDirectory(folderToRemove + folders[i] + "/");
                }

                //get all files inside it
                string[] files = store.GetFileNames(folderToRemove + "*");
                for (int i = 0; i < files.Length; i++)
                {
                    store.DeleteFile(folderToRemove + files[i]);
                }

                //finally, delete this directory once it's empty
                store.DeleteDirectory(folderToRemove.TrimEnd('/'));
            }

            catch
            {
                Debug.WriteLine("Failed to delete directory");
            }
        }
        //deleting the directory
        public static void DeleteDirectoryRecursively(this IsolatedStorageFile storageFile, String dirName)
        {
            if (!storageFile.DirectoryExists(dirName))
            {
                return;
            }
            String pattern = dirName + "/*";

            String[] files = storageFile.GetFileNames(pattern);
            foreach (String fName in files)
            {
                String temp = dirName + "/" + fName + "\n";
                if (storageFile.FileExists(temp))
                {
                    storageFile.DeleteFile(temp);
                }
            }

            String[] dirs = storageFile.GetDirectoryNames(pattern);
            foreach (String dName in dirs)
            {
                String temp = dirName + "/" + dName;
                if (storageFile.DirectoryExists(temp))
                {
                    DeleteDirectoryRecursively(storageFile, temp);
                }
            }
            storageFile.DeleteDirectory(dirName);
        }
        public static void ClearDirectory(string dirName)
        {
            IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication();

            if (!isoFile.DirectoryExists(dirName))
            {
                return;
            }

            string[] dirNames  = isoFile.GetDirectoryNames(dirName + "\\*");
            string[] fileNames = isoFile.GetFileNames(dirName + "\\*");

            if (fileNames.Length > 0)
            {
                for (int i = 0; i < fileNames.Length; i++)
                {
                    isoFile.DeleteFile(System.IO.Path.Combine(dirName, fileNames[i]));
                }
            }

            if (dirNames.Length > 0)
            {
                for (int i = 0; i < dirNames.Length; i++)
                {
                    ClearDirectory(System.IO.Path.Combine(dirName, dirNames[i]));
                    isoFile.DeleteDirectory(System.IO.Path.Combine(dirName, dirNames[i]));
                }
            }
        }
        private string EnsureDirectory()
        {
            if (this.Directory.IsEmpty())
            {
                return(string.Empty);
            }
            ModuleProc PROC   = new ModuleProc("HomeScreenWidgets", "EnsureDirectory");
            string     result = string.Empty;

            try
            {
                string[] dirNames = _storage.GetDirectoryNames(this.Directory);
                if (dirNames == null || dirNames.Length == 0)
                {
                    _storage.CreateDirectory(this.Directory);
                }
                result = this.Directory;
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(result);
        }
示例#23
0
    } // End of Main.

    // Method to retrieve all directories, recursively, within a store.
    public static List <String> GetAllDirectories(string pattern, IsolatedStorageFile storeFile)
    {
        // Get the root of the search string.
        string root = Path.GetDirectoryName(pattern);

        if (root != "")
        {
            root += "/";
        }

        // Retrieve directories.
        List <String> directoryList = new List <String>(storeFile.GetDirectoryNames(pattern));

        // Retrieve subdirectories of matches.
        for (int i = 0, max = directoryList.Count; i < max; i++)
        {
            string        directory = directoryList[i] + "/";
            List <String> more      = GetAllDirectories(root + directory + "*", storeFile);

            // For each subdirectory found, add in the base path.
            for (int j = 0; j < more.Count; j++)
            {
                more[j] = directory + more[j];
            }

            // Insert the subdirectories into the list and
            // update the counter and upper bound.
            directoryList.InsertRange(i + 1, more);
            i   += more.Count;
            max += more.Count;
        }

        return(directoryList);
    }
示例#24
0
        private void LoadFileList(string path)
        {
            using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                var fileItems = new List <FileItem>();

                string searchPattern = Path.Combine(path, "*");
                foreach (string directoryName in store.GetDirectoryNames(searchPattern))
                {
                    fileItems.Add(new FileItem()
                    {
                        Name = directoryName, Type = "directory"
                    });
                }

                foreach (string fileName in store.GetFileNames(searchPattern))
                {
                    fileItems.Add(new FileItem()
                    {
                        Name = fileName, Type = "file"
                    });
                }

                this.fileList.ItemsSource = fileItems;
            }
        }
示例#25
0
 // 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);
     }
 }
示例#26
0
        public static void ClearCache()
        {
            String tempUsername = AppUser.Instance.UserName;
            String tempPassword = AppUser.Instance.Password;

            IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

            foreach (String file in myIsolatedStorage.GetFileNames())
            {
                try
                {
                    if (file.Equals("wptrakt.sdf"))
                    {
                        if (MovieDao.Instance.DatabaseExists())
                        {
                            try
                            {
                                MovieDao.Instance.DeleteDatabase();
                                MovieDao.Instance.Dispose();
                                MovieDao.DisposeDB();
                            }
                            catch (IOException) { }
                        }

                        if (ShowDao.Instance.DatabaseExists())
                        {
                            try
                            {
                                ShowDao.Instance.DeleteDatabase();
                                ShowDao.Instance.Dispose();
                                ShowDao.DisposeDB();
                            }
                            catch (IOException) { }
                        }
                    }

                    myIsolatedStorage.DeleteFile(file);
                }
                catch (IsolatedStorageException) { };
            }

            IsolatedStorageSettings.ApplicationSettings["UserName"] = tempUsername;
            IsolatedStorageSettings.ApplicationSettings["Password"] = tempPassword;
            IsolatedStorageSettings.ApplicationSettings.Save();

            foreach (String dir in myIsolatedStorage.GetDirectoryNames())
            {
                if (!dir.Contains("Shared"))
                {
                    foreach (String file in myIsolatedStorage.GetFileNames(dir + "/*"))
                    {
                        try
                        {
                            myIsolatedStorage.DeleteFile(dir + "/" + file);
                        }
                        catch (IsolatedStorageException) { };
                    }
                }
            }
        }
示例#27
0
        public void GetDirsInSubDirs()
        {
            IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForAssembly();

            isf.CreateDirectory("subdir");
            string [] dir_names = isf.GetDirectoryNames("subdir/../*");
        }
示例#28
0
        //---------------------------------------------------------------------------------------------------------



        //Wird bei jedem Aufruf der Seite ausgeführt
        //---------------------------------------------------------------------------------------------------------------------------------
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //File erstellen
            IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();

            //Variable für Ordner ermitteln
            string[] AllFolders = file.GetDirectoryNames("/Folders/");
            int      FolderID   = Convert.ToInt32(NavigationContext.QueryString["folder"]);

            Folder = AllFolders[FolderID];
            base.OnNavigatedTo(e);

            //ImageCount laden //Anzahl erstellter Bilder
            FileStream   filestream = file.OpenFile("Settings/ImageCount.txt", FileMode.Open);
            StreamReader sr         = new StreamReader(filestream);
            String       tempSr     = sr.ReadToEnd();

            filestream.Close();
            ImageCount = Convert.ToInt32(tempSr);

            //Image.dat laden
            filestream = file.OpenFile("Thumbs/" + Folder + ".dat", FileMode.Open);
            sr         = new StreamReader(filestream);
            ImagesAll  = sr.ReadToEnd();
            filestream.Close();
            ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });

            //Bilder laden
            GetImages("first");
        }
示例#29
0
        public static bool delDirIsoStorBeforeUnzip(string dirName)
        {
            bool result;

            try
            {
                IsolatedStorageFile userStoreForApplication = IsolatedStorageFile.GetUserStoreForApplication();
                string   text      = dirName + "\\*";
                string[] fileNames = userStoreForApplication.GetFileNames(text);
                string[] array     = fileNames;
                for (int i = 0; i < array.Length; i++)
                {
                    string text2 = array[i];
                    userStoreForApplication.DeleteFile(Path.Combine(dirName, text2));
                }
                string[] directoryNames = userStoreForApplication.GetDirectoryNames(text);
                string[] array2         = directoryNames;
                for (int j = 0; j < array2.Length; j++)
                {
                    string text3 = array2[j];
                    delDirIsoStorBeforeUnzip(Path.Combine(dirName, text3));
                }
                userStoreForApplication.DeleteDirectory(dirName);
                result = true;
            }
            catch (Exception ex)
            {
                // WLUtils.LOG("cleaning or IsolatedStorage (directupdate skins)  .... " + ex);
                result = false;
            }
            return(result);
        }
示例#30
0
        private IEnumerable <string> GetAllDirectoryNames(IsolatedStorageFile isf, string rootPath)
        {
            List <string> allDirs = new List <string>();

            // Gets the paths of sub-directories of first level in rootPath.
            IEnumerable <string> subPaths;

            try
            {
                subPaths = isf
                           .GetDirectoryNames(rootPath + "/*")
                           .Select(s => rootPath + "/" + s);
            }
            catch (Exception)
            {
                subPaths = new string[] { };
            }

            // For each of them, check for sub-directories.
            foreach (string subPath in subPaths)
            {
                allDirs.AddRange(GetAllDirectoryNames(isf, subPath));
            }

            // Adds the root path to the list.
            allDirs.Add(rootPath);

            return(allDirs);
        }