本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFile类的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFile类的具体用法?C# IsolatedStorageFile怎么用?C# IsolatedStorageFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IsolatedStorageFile类属于System.IO.IsolatedStorage命名空间,在下文中一共展示了IsolatedStorageFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssemblyResourceStore
internal AssemblyResourceStore(Type evidence)
{
this.evidence = evidence;
logger = Initializer.Instance.WindsorContainer.Resolve<ILoggingService>();
_isoFile = IsolatedStorageFile.GetMachineStoreForAssembly();
_backingFile = new IsolatedStorageFileStream(evidence.Assembly.GetName().Name, FileMode.OpenOrCreate, _isoFile);
if (_backingFile.Length > 0)
{
try
{
var formatter = new BinaryFormatter();
store = (Dictionary<string, object>)formatter.Deserialize(_backingFile);
}
catch (Exception ex)
{
logger.Log(Common.LogLevel.Error, string.Format("Error deserializing resource store for {0}. Resetting resource store.", evidence.Assembly.GetName().Name));
logger.Log(Common.LogLevel.Debug, string.Format("Deserialize error: {0}", ex.Message));
store = new Dictionary<string, object>();
}
}
else
{
store = new Dictionary<string, object>();
}
}
示例2: IsolatedStorageTracer
public IsolatedStorageTracer()
{
_storageFile = IsolatedStorageFile.GetUserStoreForApplication();
_storageFileStream = _storageFile.OpenFile("MagellanTrace.log", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
_streamWriter = new StreamWriter(_storageFileStream);
_streamWriter.AutoFlush = true;
}
示例3: DynamicArchiveFileHandlerClass
public DynamicArchiveFileHandlerClass(IsolatedStorageFile isolatedStorageFile)
{
this.MaxArchiveFileToKeep = -1;
this.isolatedStorageFile = isolatedStorageFile;
archiveFileEntryQueue = new Queue<string>();
}
示例4: App
/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard Silverlight initialization
InitializeComponent();
//get store
store = IsolatedStorageFile.GetUserStoreForApplication();
// Phone-specific initialization
InitializePhoneApplication();
// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
{
// Display the current frame rate counters.
Application.Current.Host.Settings.EnableFrameRateCounter = true;
// Show the areas of the app that are being redrawn in each frame.
//Application.Current.Host.Settings.EnableRedrawRegions = true;
// Enable non-production analysis visualization mode,
// which shows areas of a page that are handed off to GPU with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
// application's PhoneApplicationService object to Disabled.
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
// and consume battery power when the user is not using the phone.
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
}
示例5: FromCache
/// <summary>
/// Imports a CartridgeSavegame from metadata associated to a savegame
/// file.
/// </summary>
/// <param name="gwsFilePath">Path to the GWS savegame file.</param>
/// <param name="isf">Isostore file to use to load.</param>
/// <returns>The cartridge savegame.</returns>
///
public static CartridgeSavegame FromCache(string gwsFilePath, IsolatedStorageFile isf)
{
// Checks that the metadata file exists.
string mdFile = gwsFilePath + ".mf";
if (!(isf.FileExists(mdFile)))
{
throw new System.IO.FileNotFoundException(mdFile + " does not exist.");
}
// Creates a serializer.
DataContractSerializer serializer = new DataContractSerializer(typeof(CartridgeSavegame));
// Reads the object.
CartridgeSavegame cs;
using (IsolatedStorageFileStream fs = isf.OpenFile(mdFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
// Reads the object.
object o = serializer.ReadObject(fs);
// Casts it.
cs = (CartridgeSavegame)o;
}
// Adds non-serialized content.
cs.SavegameFile = gwsFilePath;
cs.MetadataFile = mdFile;
// Returns it.
return cs;
}
示例6: IsolatedStorageFileStream
public IsolatedStorageFileStream(String path, FileMode mode,
FileAccess access, FileShare share,
IsolatedStorageFile sf)
: this(path, mode, access, share, BUFSIZ, sf)
{
// Nothing to do here.
}
示例7: 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);
}
}
示例8: MainPage
// Constructor
public MainPage()
{
this._WatchlistFile = IsolatedStorageFile.GetUserStoreForApplication();
this._WatchlistFileName = "Watchlist.txt";
// If the file doesn't exist we need to create it so the user has it for us to reference.
if (!this._WatchlistFile.FileExists(this._WatchlistFileName))
{
this._WatchlistFile.CreateFile(this._WatchlistFileName).Close();
}
this._WatchList = this._ReadWatchlistFile();
InitializeComponent();
// Init WebClient's and set callbacks
this._LookupWebClient = new WebClient();
this._LookupWebClient.OpenReadCompleted += new OpenReadCompletedEventHandler(this.LookupSymbolComplete);
this._NewsWebClient = new WebClient();
this._NewsWebClient.OpenReadCompleted += new OpenReadCompletedEventHandler(this.NewsSearchComplete);
this._QuoteWebClient = new WebClient();
this._QuoteWebClient.OpenReadCompleted += new OpenReadCompletedEventHandler(this.GetQuoteComplete);
this.SymbolTextBox.Text = _DefaultInputText;
}
示例9: 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);
}
}
示例10: Note
/// <summary>
/// Create a Note instance and create a note file.
/// </summary>
/// <param name="title"></param>
/// <param name="body"></param>
/// <param name="iStorage"></param>
/// <param name="dateTime"></param>
public Note(string title, DateTime dateTime, string body, IsolatedStorageFile iStorage)
{
Title = title;
DateTime = dateTime;
Body = body;
SaveFromTitle(iStorage);
}
示例11: BaseStorageCache
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);
}
示例12: SetupApplicationViewModel
public SetupApplicationViewModel(IGlobalSettingsService globalSettingsService)
{
_storage = IsolatedStorageFile.GetUserStoreForApplication();
CacheModules = globalSettingsService.IsCachingEnabled;
Quota = _storage.Quota / 1048576;
_globalSettingsService = globalSettingsService;
}
示例13: LoadSettings
public void LoadSettings()
{
// Look for settings in isolated storage
this.isoStore = IsolatedStorageFile.GetUserStoreForAssembly();
//this.isoStore.DeleteFile("Prefs.txt");
string[] files = this.isoStore.GetFileNames(prefsFilename);
if (files.Length > 0)
{
using (StreamReader reader = new StreamReader(new IsolatedStorageFileStream(prefsFilename, FileMode.Open, this.isoStore)))
{
// Decrypt the stream
string decrypted = Encryption.Decrypt(reader.ReadToEnd(), key, false);
StringReader sr = new StringReader(decrypted);
// Deserialize the settings
XmlSerializer serializer = new XmlSerializer(this.GetType());
BackupSettings settings = (BackupSettings)serializer.Deserialize(sr);
// Set properties
this.ServerUrl = settings.ServerUrl;
this.AuthenticationKey = settings.AuthenticationKey;
this.CertificateIdentity = settings.CertificateIdentity;
this.StorageAccounts = settings.StorageAccounts;
}
}
}
示例14: IsolatedStorageFileStorage
public IsolatedStorageFileStorage()
{
__IsoStorage =
IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly,
null,
null);
}
示例15: Setup
public override void Setup()
{
base.Setup ();
Device.PlatformServices = new MockPlatformServices (getStreamAsync: GetStreamAsync);
NativeStore = IsolatedStorageFile.GetUserStoreForAssembly ();
networkcalls = 0;
}