protected BaseStorageCache(IsolatedStorageFile isf, string cacheDirectory, ICacheFileNameGenerator cacheFileNameGenerator, long cacheMaxLifetimeInMillis = DefaultCacheMaxLifetimeInMillis) { if (isf == null) { throw new ArgumentNullException("isf"); } if (String.IsNullOrEmpty(cacheDirectory)) { throw new ArgumentException("cacheDirectory name could not be null or empty"); } if (!cacheDirectory.StartsWith("\\")) { throw new ArgumentException("cacheDirectory name should starts with double slashes: \\"); } if (cacheFileNameGenerator == null) { throw new ArgumentNullException("cacheFileNameGenerator"); } ISF = isf; CacheDirectory = cacheDirectory; CacheFileNameGenerator = cacheFileNameGenerator; CacheMaxLifetimeInMillis = cacheMaxLifetimeInMillis; // Creating cache directory if it not exists ISF.CreateDirectory(CacheDirectory); }
private static void VerifyFolderExistsAsync(IsolatedStorageFile isolatedStorageFile) { if (!isolatedStorageFile.DirectoryExists(MonthFolder)) { isolatedStorageFile.CreateDirectory(MonthFolder); } }
public IsolatedStorageDirectory(string dirName) { _is = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly(); _dirName = dirName; _is.CreateDirectory(dirName); }
public SelProj() { InitializeComponent(); isf = IsolatedStorageFile.GetUserStoreForAssembly(); isf.CreateDirectory("conf"); Refr(); }
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); } }
/// <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) { 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); }
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 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++; } }
private ScreenShots() { _isf = IsolatedStorageFile.GetUserStoreForApplication(); try { _isf.CreateDirectory("screenshots"); } catch { // OK the directory already exists. } }
/// <summary> /// �ڴ洢���ڴ���Ŀ¼ /// </summary> /// <param name="storage"></param> /// <param name="dirName"></param> public static void CreateDirectory(IsolatedStorageFile storage, string dirName) { try { if (!string.IsNullOrEmpty(dirName) && storage.GetDirectoryNames(dirName).Length > 0) { storage.CreateDirectory(dirName); } } catch (Exception ex) { throw new Exception("���ڴ洢���ڴ���Ŀ¼.", ex); } }
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> /// 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); }
// use the caller stack to execute some write operations private void Write (IsolatedStorageFile isf) { isf.CreateDirectory ("testdir"); string filename = Path.Combine ("testdir", "file"); using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream (filename, FileMode.Create, isf)) { } isf.DeleteFile (filename); isf.DeleteDirectory ("testdir"); try { isf.Remove (); } catch (IsolatedStorageException) { // fx 1.x doesn't like removing when things "could" still be in use } }
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); } }
/// <summary> /// 保存信息至本地文件,SilverLight缓存中 /// </summary> /// <param name="rFileName"></param> /// <param name="buffer"></param> public static void WriteSlByteFile(string rFileName, byte[] buffer) { System.IO.IsolatedStorage.IsolatedStorageFile isf = null; System.IO.Stream stream = null; try { isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); if (rFileName.IndexOf(':') >= 0) { rFileName = rFileName.Substring(rFileName.LastIndexOf(':') + 1); } ClearSlFile(rFileName); string rPath = System.IO.Path.GetDirectoryName(rFileName); if (rPath != "") { isf.CreateDirectory(rPath); } stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream(rFileName, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.Write, isf); stream.Write(buffer, 0, buffer.Length); stream.Flush(); } finally { try { stream.Close(); // Close the stream too stream.Dispose(); isf.Dispose(); } catch { } } }
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 void Initialize() { store = IsolatedStorageFile.GetUserStoreForDomain(); store.CreateDirectory(storageAreaName); }
/// <summary> /// Creates or replaces the underlying savegame file and opens a writing /// stream for it. /// </summary> /// <param name="isf">Isolated storage to use.</param> /// <returns>The stream to write the savegame on.</returns> public System.IO.Stream CreateOrReplace(IsolatedStorageFile isf) { // Makes sure the containing directory exists. isf.CreateDirectory(System.IO.Path.GetDirectoryName(SavegameFile)); // Returns the stream to SavegameFile. return isf.OpenFile(SavegameFile, System.IO.FileMode.Create, System.IO.FileAccess.Write); }
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; }
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); } } }
/// <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); } }
/// <summary> /// 确保Cache文件夹存在 /// </summary> private void EnsureCacheFolder() { using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) { if ( !_storage.DirectoryExists( CACHE_FOLDER ) ) { _storage.CreateDirectory( CACHE_FOLDER ); } } }
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) }); }
// 构造函数 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 }
private void InitializeStore() { store = IsolatedStorageFile.GetUserStoreForDomain(); store.CreateDirectory("Enterprise Library"); storageArea = Path.Combine("Enterprise Library", this.form.GetType().Name); }
public void CreateIsolatedStorage() { storage = IsolatedStorageFile.GetUserStoreForDomain(); storage.CreateDirectory(DirectoryName); }
public override Task CreateDirectoryAsync(string path) { return(Task.Factory.StartNew(() => file.CreateDirectory(path))); }