本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFile.GetFileNames方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFile.GetFileNames方法的具体用法?C# IsolatedStorageFile.GetFileNames怎么用?C# IsolatedStorageFile.GetFileNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFile
的用法示例。
在下文中一共展示了IsolatedStorageFile.GetFileNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFiles
private static void GetFiles(string dir, string pattern, IsolatedStorageFile storeFile)
{
string fileString = System.IO.Path.GetFileName(pattern);
string[] files = storeFile.GetFileNames(pattern);
try
{
for (int i = 0; i < storeFile.GetFileNames(dir + "/" + fileString).Length; i++)
{
//Files are prefixed with "--"
//Add to the list
//listDir.Add("--" + dir + "/" + storeFile.GetFileNames(dir + "/" + fileString)[i]);
Debug.WriteLine("--" + dir + "/" + storeFile.GetFileNames(dir + "/" + fileString)[i]);
}
}
catch (IsolatedStorageException ise)
{
Debug.WriteLine("An IsolatedStorageException exception has occurred: " + ise.InnerException);
}
catch (Exception e)
{
Debug.WriteLine("An exception has occurred: " + e.InnerException);
}
}
示例2: 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;
}
示例3: GetAllFiles
public static List<String> GetAllFiles(string pattern, IsolatedStorageFile storeFile)
{
// Get the root and file portions of the search string.
string fileString = Path.GetFileName(pattern);
List<String> fileList = new List<String>(storeFile.GetFileNames(pattern));
// Loop through the subdirectories, collect matches,
// and make separators consistent.
foreach (string directory in GetAllDirectories("*", storeFile))
{
foreach (string file in storeFile.GetFileNames(directory + "/" + fileString))
{
fileList.Add((directory + "/" + file));
}
}
return fileList;
}
示例4: 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
}
}
示例5: DeleteAllFilesInDirectory
private void DeleteAllFilesInDirectory(IsolatedStorageFile store, string path)
{
if (!store.DirectoryExists(path))
{
return;
}
var files = store.GetFileNames(path + "/*");
foreach (var file in files)
{
store.DeleteFile(path + "/" + file);
}
}
示例6: 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);
}
}
示例7: Clear
public override void Clear()
{
base.Clear();
using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) {
try {
foreach ( string file in _storage.GetFileNames( CACHE_FOLDER + @"\*" ) ) {
_storage.DeleteFile( GetFilePath( file ) );
}
}
catch ( Exception e ) {
e.ToString();
}
}
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: IsolatedStorageCrawlerQueueService
public IsolatedStorageCrawlerQueueService(Uri crawlStart, bool resume)
{
m_CrawlStart = crawlStart;
m_Store = IsolatedStorageFile.GetMachineStoreForDomain();
if (!resume)
{
Clean();
}
else
{
Initialize();
m_Count = m_Store.GetFileNames(Path.Combine(WorkFolderPath, "*")).Count();
}
}
示例12: CleanupLogs
private static void CleanupLogs(IsolatedStorageFile store, string logFolder)
{
var files = store.GetFileNames(logFolder);
var fileCount = files.Count();
if (fileCount > MAX_FILE_COUNT - 1)
{
var filesAgeAsc = from file in files
let age = store.GetCreationTime(file)
orderby age ascending
select file;
var deleteFiles = filesAgeAsc.Take(fileCount - MAX_FILE_COUNT + 1);
foreach (var file in deleteFiles)
{
var filePath = Path.Combine(logFolder, file);
store.DeleteFile(filePath);
}
}
}
示例13: TryToDeleteAllFiles
public static void TryToDeleteAllFiles(IsolatedStorageFile storageFolder, string directory)
{
if (storageFolder.DirectoryExists(directory))
{
try
{
string[] files = storageFolder.GetFileNames(directory);
foreach (string File in files)
{
storageFolder.DeleteFile(directory + files);
}
}
catch (Exception)
{
//ignoring the exception
}
}
}
示例14: TryToDeleteAllFiles
/// <summary>
/// delete files in directory
/// </summary>
/// <param name="storageFolder"></param>
/// <param name="directory"></param>
private static void TryToDeleteAllFiles(IsolatedStorageFile storageFolder, string directory)
{
if (storageFolder.DirectoryExists(directory))
{
try
{
string[] files = storageFolder.GetFileNames(directory);
foreach (string file in files)
{
storageFolder.DeleteFile(directory + file);
}
}
catch (Exception)
{
// could be in use
}
}
}
示例15: 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);
}