当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageFile.GetDirectoryNames方法代码示例

本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFile.GetDirectoryNames方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFile.GetDirectoryNames方法的具体用法?C# IsolatedStorageFile.GetDirectoryNames怎么用?C# IsolatedStorageFile.GetDirectoryNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.IsolatedStorage.IsolatedStorageFile的用法示例。


在下文中一共展示了IsolatedStorageFile.GetDirectoryNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetIsolatedStorageView

        //*******************************************************************************************
        //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);
            }
        }
开发者ID:bramleffers,项目名称:MonkeySpace,代码行数:41,代码来源:IsoViewer.cs

示例2: GetAllDirectories

        // 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;
        }
开发者ID:NBitionDevelopment,项目名称:WindowsPhoneFeedBoard,代码行数:35,代码来源:FileHelper.cs

示例3: CollectSubdirectoriesAndFilesBreadthFirst

        /// <summary>
        /// Collects the Paths of Directories and Files inside a given Directory relative to it.
        /// </summary>
        /// <param name="Iso">The Isolated Storage to Use</param>
        /// <param name="directory">The Directory to crawl</param>
        /// <param name="relativeSubDirectories">relative Paths to the subdirectories in the given directory, ordered top - down</param>
        /// <param name="relativeSubFiles">relative Paths to the files in the given directory and its children, ordered top - down</param>
        private static void CollectSubdirectoriesAndFilesBreadthFirst(IsolatedStorageFile Iso, string directory, out IList<string> relativeSubDirectories, out IList<string> relativeSubFiles)
        {
            var relativeDirs = new List<string>();
            var relativeFiles = new List<string>();
            var toDo = new Queue<string>();

            toDo.Enqueue(string.Empty);

            while (toDo.Count > 0)
            {
                var relativeSubDir = toDo.Dequeue();
                var absoluteSubDir = Path.Combine(directory, relativeSubDir);
                var queryString = string.Format("{0}\\*", absoluteSubDir);

                foreach (var file in Iso.GetFileNames(queryString))
                {
                    relativeFiles.Add(Path.Combine(relativeSubDir, file));
                }

                foreach (var dir in Iso.GetDirectoryNames(queryString))
                {
                    var relativeSubSubdir = Path.Combine(relativeSubDir, dir);
                    toDo.Enqueue(relativeSubSubdir);
                    relativeDirs.Add(relativeSubSubdir);
                }
            }

            relativeSubDirectories = relativeDirs;
            relativeSubFiles = relativeFiles;
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:37,代码来源:IsolatedStorageExtensions.cs

示例4: 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

示例5: Read

		// use the caller stack to execute some read operations
		private void Read (IsolatedStorageFile isf)
		{
			Assert.IsNotNull (isf.GetDirectoryNames ("*"), "GetDirectoryNames");
			Assert.IsNotNull (isf.GetFileNames ("*"), "GetFileNames");
			try {
				Assert.IsTrue (isf.CurrentSize >= 0, "CurrentSize");
				Assert.IsTrue (isf.MaximumSize >= isf.CurrentSize, "MaximumSize");
			}
			catch (InvalidOperationException) {
				// roaming
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:13,代码来源:IsolatedStorageFileCas.cs

示例6: 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

示例7: 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

示例8: IsolatedStorageCacheItem

        /// <summary>
        /// Instance constructor. Ensures that the storage location in Isolated Storage is prepared
        /// for reading and writing. This class stores each individual field of the CacheItem into its own
        /// file inside the directory specified by itemDirectoryRoot.
        /// </summary>
        /// <param name="storage">Isolated Storage area to use. May not be null.</param>
        /// <param name="itemDirectoryRoot">Complete path in Isolated Storage where the cache item should be stored. May not be null.</param>
        /// <param name="encryptionProvider">Encryption provider</param>
        public IsolatedStorageCacheItem(IsolatedStorageFile storage, string itemDirectoryRoot, IStorageEncryptionProvider encryptionProvider)
        {
			if (storage.GetDirectoryNames(itemDirectoryRoot).Length == 0)
			{
				// avoid creating if already exists - work around for partial trust
				storage.CreateDirectory(itemDirectoryRoot);
			}

            keyField = new IsolatedStorageCacheItemField(storage, "Key", itemDirectoryRoot, encryptionProvider);
            valueField = new IsolatedStorageCacheItemField(storage, "Val", itemDirectoryRoot, encryptionProvider);
            scavengingPriorityField = new IsolatedStorageCacheItemField(storage, "ScPr", itemDirectoryRoot, encryptionProvider);
            refreshActionField = new IsolatedStorageCacheItemField(storage, "RA", itemDirectoryRoot, encryptionProvider);
            expirationsField = new IsolatedStorageCacheItemField(storage, "Exp", itemDirectoryRoot, encryptionProvider);
            lastAccessedField = new IsolatedStorageCacheItemField(storage, "LA", itemDirectoryRoot, encryptionProvider);
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:23,代码来源:IsolatedStorageCacheItem.cs

示例9: 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

示例10: 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

示例11: 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

示例12: CopyDirectory

        public void CopyDirectory(string sourcePath, string destinationPath, IsolatedStorageFile iso)
        {
            if (!iso.DirectoryExists(sourcePath))
            return;

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

              foreach (var folder in folders)
              {
            string sourceFolderPath = sourcePath + "/" + folder;
            string destinationFolderPath = destinationPath + "/" + folder;

            iso.CreateDirectory(destinationFolderPath);
            CopyDirectory(sourceFolderPath, destinationFolderPath, iso);
              }

              foreach (var file in iso.GetFileNames(sourcePath + "/" + "*.*"))
              {
            string sourceFilePath = sourcePath + "/" + file;
            string destinationFilePath = destinationPath + "/" + file;

            iso.CopyFile(sourceFilePath, destinationFilePath);
              }
        }
开发者ID:msachs,项目名称:TestRepo2,代码行数:24,代码来源:StoragePhone7.cs

示例13: Initialize

        private void Initialize()
        {
            #if WINDOWS_PHONE
            store = IsolatedStorageFile.GetUserStoreForApplication();
            #else
            // Application-scoped IS requires ClickOnce security, which we don't
            //want to depend on in the regular Windows environment
            // WP7 apps are always deployed with manifests, though, so it is not an issue
            // http://blogs.msdn.com/b/shawnhar/archive/2010/12/16/isolated-storage-windows-and-clickonce.aspx
            store = IsolatedStorageFile.GetUserStoreForDomain();
            #endif
            if (store.GetDirectoryNames(storageAreaName).Length == 0)
            {
                // avoid creating if already exists - work around for partial trust
                store.CreateDirectory(storageAreaName);
            }

            serializer = new XmlSerializer(typeof(List<ItemModel>), new Type[] { typeof(ItemModel) });
        }
开发者ID:yadyn,项目名称:ItsBeen,代码行数:19,代码来源:IsolatedStorageItemService.cs

示例14: getFiles

        private Collection<SearchableFile> getFiles(string pattern, IsolatedStorageFile storeFile, Collection<SearchableFile> list)
        {
            string root = System.IO.Path.GetDirectoryName(pattern);

            foreach (string fileName in storeFile.GetFileNames(pattern))
            {
                string filePath = System.IO.Path.Combine(root, fileName);
                string fileText = string.Empty;
                using (StreamReader myReader = new StreamReader(new IsolatedStorageFileStream(filePath, FileMode.Open, storeFile)))
                {
                    fileText = myReader.ReadToEnd();
                }
                list.Add(new SearchableFile(filePath, fileName, root, storeFile.GetLastWriteTime(filePath), fileText));
            }

            foreach (string dirName in storeFile.GetDirectoryNames(pattern))
            {
                pattern = System.IO.Path.Combine(root, dirName);
                list = getFiles(pattern + "/*", storeFile, list);
            }

            return list;
        }
开发者ID:hmehart,项目名称:Notepad,代码行数:23,代码来源:Searcher.cs

示例15: AddFileToDirectory

        // 用递归方法增加目录/文件
        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 + "/");
            }

            // 增加目录实体
            foreach (var dirname in childrendir)
            {
                var childdir = new IsoDirectory(dirname, dir.FilePath + "/" + dirname);
                AddFileToDirectory(childdir, isf);
                dir.Children.Add(childdir);
            }

            // 增加文件实体
            foreach (var filename in childrenfile)
            {
                dir.Children.Add(new IsoFile(filename, dir.FilePath + "/" + filename));
            }
        }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:29,代码来源:MainPage.xaml.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFile.GetDirectoryNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。