本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFile.DirectoryExists方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFile.DirectoryExists方法的具体用法?C# IsolatedStorageFile.DirectoryExists怎么用?C# IsolatedStorageFile.DirectoryExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFile
的用法示例。
在下文中一共展示了IsolatedStorageFile.DirectoryExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyFolderExistsAsync
private static void VerifyFolderExistsAsync(IsolatedStorageFile isolatedStorageFile)
{
if (!isolatedStorageFile.DirectoryExists(MonthFolder))
{
isolatedStorageFile.CreateDirectory(MonthFolder);
}
}
示例2: AssemblyStorageService
public AssemblyStorageService()
{
Store = IsolatedStorageFile.GetUserStoreForApplication();
Store.IncreaseQuotaTo(20971520);
if (!Store.DirectoryExists("Modules"))
Store.CreateDirectory("Modules");
}
示例3: IsolatedStorageResponseCache
public IsolatedStorageResponseCache(TimeSpan expiresIn)
{
this.expiresIn = expiresIn;
storage = IsolatedStorageFile.GetUserStoreForApplication();
if (!storage.DirectoryExists("Cache"))
{
storage.CreateDirectory("Cache");
}
}
示例4: CreateDirectoryTree
public static void CreateDirectoryTree(Uri feedUri, IsolatedStorageFile storage)
{
if (!feedUri.OriginalString.Contains('\\')) return;
var directory = GetDirectoryPath(feedUri);
if (!storage.DirectoryExists(directory))
storage.CreateDirectory(directory);
}
示例5: IsolatedStorageResponseCache
public IsolatedStorageResponseCache(string session)
{
if (session == null) throw new ArgumentNullException("session");
this._sessionKey = HashUtil.ToSHA1(session);
//create cache dir
_storage = IsolatedStorageFile.GetUserStoreForApplication();
if (!_storage.DirectoryExists("ECollegeCache"))
{
_storage.CreateDirectory("ECollegeCache");
}
//create session dir
string thisSessionDirectory = string.Format("ECollegeCache\\{0}", _sessionKey);
if (!_storage.DirectoryExists(thisSessionDirectory))
{
_storage.CreateDirectory(thisSessionDirectory);
}
}
示例6: 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);
}
}
示例7: CreateDirectoryTree
/// <summary>
/// Creates all of the directories included in the given filepath.
/// </summary>
/// <param name="filepath">A string containing a filepath which may or may not contain any number of directories.</param>
/// <param name="storage">A reference to a valid IsolatedStorageFile instance</param>
public static void CreateDirectoryTree(string filepath, IsolatedStorageFile storage)
{
//If this filepath is flat and doesn't contain any folders - bail.
if (!HasDirectories(filepath)) return;
//Extract the full directory path from the filename
var directory = GetFullDirectoryPath(filepath);
//If the directory doesn't already exist, create it.
if (!storage.DirectoryExists(directory))
storage.CreateDirectory(directory);
}
示例8: CreateDirIfNecessary
private void CreateDirIfNecessary(IsolatedStorageFile local, string path)
{
int pos = 0;
string dir = path;
while ((pos = dir.IndexOf('\\', pos)) != -1)
{
var dirname = dir.Substring(0, pos);
if (!local.DirectoryExists(dirname))
local.CreateDirectory(dirname);
pos++;
}
}
示例9: MainPage
public MainPage()
{
InitializeComponent();
_recorder = new Recorder(new WaveFormat());
_storage = IsolatedStorageFile.GetUserStoreForApplication();
if (!_storage.DirectoryExists(STORAGE_DIRECTORY))
{
_storage.CreateDirectory(STORAGE_DIRECTORY);
}
UpdateRecordings();
}
示例10: CheckDir
private static bool CheckDir(IsolatedStorageFile storage)
{
if (!storage.DirectoryExists(Folder))
{
try
{
storage.CreateDirectory(Folder);
}
catch (Exception)
{
return false;
}
}
return true;
}
示例11: 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
}
}
}
示例12: 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
}
}
}
示例13: OpenLogFile
private static Stream OpenLogFile(IsolatedStorageFile store)
{
if (Profile == null)
{
return Stream.Null;
}
try
{
var fileName = string.Format(LOGFILE_TEMPLATE, DateTime.UtcNow.ToString("yyyy-MM-dd"));
var folderPath = Path.Combine(Profile.CurrentProfilePath(), LOGFOLDER);
if (!store.DirectoryExists(folderPath))
{
store.CreateDirectory(folderPath);
}
var filePath = Path.Combine(folderPath, fileName);
if (store.FileExists(filePath))
{
return store.OpenFile(filePath, FileMode.Append);
}
else
{
CleanupLogs(store, folderPath);
return store.OpenFile(filePath, FileMode.Create);
}
}
catch (Exception ex)
{
// Logging Failed, don't kill the process because of it
Debugger.Break();
return Stream.Null;
}
}
示例14: 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);
}
}
示例15: ExtractFile
private bool ExtractFile(StreamResourceInfo xapStream, IsolatedStorageFile isf, string fileName)
{
try
{
if (!isf.DirectoryExists("Temp"))
isf.CreateDirectory("Temp");
if (!isf.DirectoryExists(IsoTempFolderPath))
isf.CreateDirectory(IsoTempFolderPath);
var streamResource = Application.GetResourceStream(xapStream, new Uri(fileName, UriKind.Relative));
if (streamResource == null)
return false;
string shortFileName = ShortenFileName(fileName);
var fs = new IsolatedStorageFileStream(IsoTempFolderPath + "\\" + shortFileName, FileMode.Create, isf);
Byte[] bytes = new Byte[streamResource.Stream.Length];
streamResource.Stream.Read(bytes, 0, bytes.Length);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
streamResource.Stream.Close();
return true;
}
catch (Exception ex)
{
}
return false;
}