private static void VerifyFolderExistsAsync(IsolatedStorageFile isolatedStorageFile) { if (!isolatedStorageFile.DirectoryExists(MonthFolder)) { isolatedStorageFile.CreateDirectory(MonthFolder); } }
public AssemblyStorageService() { Store = IsolatedStorageFile.GetUserStoreForApplication(); Store.IncreaseQuotaTo(20971520); if (!Store.DirectoryExists("Modules")) Store.CreateDirectory("Modules"); }
public IsolatedStorageResponseCache(TimeSpan expiresIn) { this.expiresIn = expiresIn; storage = IsolatedStorageFile.GetUserStoreForApplication(); if (!storage.DirectoryExists("Cache")) { storage.CreateDirectory("Cache"); } }
public static void CreateDirectoryTree(Uri feedUri, IsolatedStorageFile storage) { if (!feedUri.OriginalString.Contains('\\')) return; var directory = GetDirectoryPath(feedUri); if (!storage.DirectoryExists(directory)) storage.CreateDirectory(directory); }
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); } }
public static void CreateDirectory(string path) { System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (isf.DirectoryExists(path)) { isf.CreateDirectory(path); } }
/// <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); }
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); } }
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++; } }
public MainPage() { InitializeComponent(); _recorder = new Recorder(new WaveFormat()); _storage = IsolatedStorageFile.GetUserStoreForApplication(); if (!_storage.DirectoryExists(STORAGE_DIRECTORY)) { _storage.CreateDirectory(STORAGE_DIRECTORY); } UpdateRecordings(); }
private static bool CheckDir(IsolatedStorageFile storage) { if (!storage.DirectoryExists(Folder)) { try { storage.CreateDirectory(Folder); } catch (Exception) { return false; } } return true; }
/// <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 } } }
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 } } }
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; } }
/// <summary> /// 保存信息至本地文件,SilverLight缓存中 /// </summary> /// <param name="rFileName">存储文件名</param> /// <param name="rText">消息文本</param> public static void WriteSlTextFile(string rFileName, string rText) { System.IO.IsolatedStorage.IsolatedStorageFile isf = null; System.IO.Stream stream = null; System.IO.TextWriter writer = null; try { isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (rFileName.IndexOf(':') >= 0) { rFileName = rFileName.Substring(rFileName.LastIndexOf(':') + 1); } string rPath = System.IO.Path.GetDirectoryName(rFileName); if (isf.DirectoryExists(rPath) == false) { isf.CreateDirectory(rPath); } stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream(rFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, isf); //stream.Seek(0, System.IO.SeekOrigin.End); writer = new System.IO.StreamWriter(stream); writer.Write(rText); writer.Flush(); } finally { try { writer.Close(); stream.Close(); isf.Dispose(); } catch { } } }
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); } }
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); }
private static string PrepareFilePath(DownloadItemDataModel item, IsolatedStorageFile storage) { if (item.BookID == Guid.Empty || !storage.DirectoryExists(item.BookID.ToString())) { item.BookID = CreateFolder(storage); } var bookPath = CreateBookPath(item); if (storage.FileExists(bookPath)) { storage.DeleteFile(bookPath); } return bookPath; }
public static void EnsurePath(IsolatedStorageFile store, string filename) { for (string path = Path.GetDirectoryName(filename); path != ""; path = Path.GetDirectoryName(path)) { if (!store.DirectoryExists(path)) { store.CreateDirectory(path); } } }
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; }
/// <summary> /// 确保Cache文件夹存在 /// </summary> private void EnsureCacheFolder() { using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) { if ( !_storage.DirectoryExists( CACHE_FOLDER ) ) { _storage.CreateDirectory( CACHE_FOLDER ); } } }
/// <summary> /// Saves user password. /// </summary> /// <param name="store">The store.</param> /// <param name="xml">The XML.</param> private async void Save(IsolatedStorageFile store, DbPersistentData xml) { if (!store.DirectoryExists(Folder)) store.CreateDirectory(Folder); using (var fs = store.CreateFile(ProtectionPath)) { var protect = xml.Protection; fs.Write(protect, 0, protect.Length); } using (var fs = store.CreateFile(ParsedXmlPath)) using (var buffer = new MemoryStream(xml.Xml)) BufferEx.CopyStream(buffer, fs); using (var fs = store.CreateFile(MasterPasswordPath)) { var data = xml.MasterKey; await fs.WriteAsync(data, 0, data.Length); } }
private static string PrepareFilePath(Book item, IsolatedStorageFile storage) { if (item.IsMyBook || item.IsFreeBook) { if (!storage.DirectoryExists(item.Id.ToString())) { storage.CreateDirectory(Path.Combine(CatalogPath, item.Id.ToString())); } } else { if (!storage.DirectoryExists(item.Id + ".trial")) { storage.CreateDirectory(Path.Combine(CatalogPath, item.Id + ".trial")); } } var bookPath = item.IsMyBook || item.IsFreeBook ? CreateBookPath(item.Id.ToString()) : CreateBookPath(item.Id + ".trial"); if (storage.FileExists(bookPath)) { storage.DeleteFile(bookPath); } return bookPath; }
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); } }
private static void CreateDirIfNecessary(IsolatedStorageFile iso, string dir) { if (!iso.DirectoryExists(dir)) { iso.CreateDirectory(dir); } }
/// <summary> /// Verifies whether or not a given directory exists in IsolatedStorage /// </summary> /// <param name="directorypath">The path to a given directory</param> /// <param name="storage">A reference to a valid IsolatedStorageFile instance.</param> /// <returns>True if the directory exists, false otherwise.</returns> public static bool DirectoryExists(string directorypath, IsolatedStorageFile storage) { return storage.DirectoryExists(directorypath); }
// 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); } }
private static void TryToDeleteAllFiles( IsolatedStorageFile storagefolder, string Directory) { if (storagefolder.DirectoryExists(Directory)) { try { string[] files = storagefolder.GetFileNames(Directory); foreach (var item in files) { storagefolder.DeleteFile(Directory+item); } } catch (Exception) { //In Use throw; } } }
// 构造函数 public MainPage() { InitializeComponent(); this.lat = 0.0; this.lon = 0.0; this.zoomlevel = MIN_ZOOM_LEVEL; this.targetZoomLevel = 19; this.scale = 1; this.threshold = getDPI() * 0.06f; this.hasTarget = false; this.isTracking = false; this.hasPosition = false; plotterHelper = new PlotterHelper(); westCampus = new iustc.map.data.Rectangle(31.836497, 31.844080, 117.245445, 117.255058); eastCamput = new iustc.map.data.Rectangle(31.834236, 31.844189, 117.258920, 117.267889); arrowUri = new Uri("/iUSTCMap;component/resources/map_location_arrow.png", UriKind.Relative); dotUri = new Uri("/iUSTCMap;component/resources/map_location_dot.png", UriKind.Relative); arrowBitmap = new BitmapImage(arrowUri); dotBitmap = new BitmapImage(dotUri); if (cm == null) cm = new CacheManager(CACHE_CAPACITY, this); if (pThread == null) pThread = new PlotterThread(cm); watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255, 236, 236, 236)); isoFile = IsolatedStorageFile.GetUserStoreForApplication(); if (!isoFile.DirectoryExists("cache")) { isoFile.CreateDirectory("cache"); } #region appBar appBar = new ApplicationBar(); appBar.Opacity = 0.5; locateButton = new ApplicationBarIconButton(new Uri("resources/appbar.locate.rest.png", UriKind.Relative)); locateButton.Text = "定位"; locateButton.Click += new EventHandler(locateButton_Click); appBar.Buttons.Add(locateButton); zoomInButton = new ApplicationBarIconButton(new Uri("resources/appbar.new.rest.png", UriKind.Relative)); zoomInButton.Text = "放大"; zoomInButton.Click += new EventHandler(zoomInButton_Click); appBar.Buttons.Add(zoomInButton); zoomOutButton = new ApplicationBarIconButton(new Uri("resources/appbar.minus.rest.png", UriKind.Relative)); zoomOutButton.Text = "缩小"; zoomOutButton.Click += new EventHandler(zoomOutButton_Click); appBar.Buttons.Add(zoomOutButton); selectCampusButton = new ApplicationBarIconButton(new Uri("resources/appbar.east.rest.png", UriKind.Relative)); selectCampusButton.Text = "东校区"; selectCampusButton.Click += new EventHandler(selectCampusButton_Click); appBar.Buttons.Add(selectCampusButton); ApplicationBar = appBar; #endregion }
static Storage() { storage = IsolatedStorageFile.GetUserStoreForAssembly(); if (!storage.DirectoryExists(rootDirectory)) storage.CreateDirectory(rootDirectory); }
private void CopyDirectory(string sourceDir, string destDir, IsolatedStorageFile isoFile) { string path = File.AddSlashToDirectory(sourceDir); bool bExists = isoFile.DirectoryExists(destDir); if (!bExists) { 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, true); } } string[] dirs = isoFile.GetDirectoryNames(path + "*"); if (dirs.Length > 0) { foreach (string dir in dirs) { CopyDirectory(path + dir, destDir + dir, isoFile); } } }
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); }
public override Task <bool> GetDirectoryExistsAsync(string path) { return(Task <bool> .Factory.StartNew(() => file.DirectoryExists(path))); }