本文整理汇总了C#中System.IO.IsolatedStorage.IsolatedStorageFile.FileExists方法的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageFile.FileExists方法的具体用法?C# IsolatedStorageFile.FileExists怎么用?C# IsolatedStorageFile.FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.IsolatedStorage.IsolatedStorageFile
的用法示例。
在下文中一共展示了IsolatedStorageFile.FileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Accelerometro
public Accelerometro()
{
InitializeComponent();
accelerometer = new Accelerometer();
accelerometer.TimeBetweenUpdates = TimeSpan.FromMilliseconds(100);
accelerometer.Start();
myFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!myFile.FileExists("Impo.txt"))
{
IsolatedStorageFileStream dataFile = myFile.CreateFile("Impo.txt");
dataFile.Close();
}
Wb = new WebBrowser();
Connesso = false;
Carica();
System.Windows.Threading.DispatcherTimer dt = new System.Windows.Threading.DispatcherTimer();
dt.Interval = new TimeSpan(0, 0, 0, 0, 250); // 500 Milliseconds
dt.Tick += new EventHandler(dt_Tick);
dt.Start();
}
示例3: ThrowMappedException
private static void ThrowMappedException(Exception e, string path, IsolatedStorageFile store)
{
if (store.FileExists(path))
{
throw new DatabaseFileLockedException(path, e);
}
throw new Db4oIOException(e);
}
示例4: MainPage
public MainPage()
{
InitializeComponent();
myFile = IsolatedStorageFile.GetUserStoreForApplication();
if (!myFile.FileExists("Impo.txt"))
{
IsolatedStorageFileStream dataFile = myFile.CreateFile("Impo.txt");
dataFile.Close();
}
}
示例5: Contains
/// <summary>
/// 覆盖基类实现,因为还有硬盘缓存
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public override bool Contains( string url )
{
bool cachedInMem = base.Contains( url );
if ( cachedInMem ) {
return true;
}
else {
using ( _storage = IsolatedStorageFile.GetUserStoreForApplication() ) {
String filePath = GetFilePath( GetFileName( url ) );
return _storage.FileExists( filePath );
}
}
}
示例6: SafeDeleteFile
public static void SafeDeleteFile(IsolatedStorageFile storage, string fileName)
{
try
{
if (storage.FileExists(fileName))
{
storage.DeleteFile(fileName);
}
}
catch (Exception)
{
}
}
示例7: CopyToIsolatedStorage
private static void CopyToIsolatedStorage(string file, IsolatedStorageFile store, bool overwrite = true)
{
if (store.FileExists(file) && !overwrite)
return;
using (Stream resourceStream = Application.GetResourceStream(new Uri(file, UriKind.Relative)).Stream)
using (IsolatedStorageFileStream fileStream = store.OpenFile(file, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
int bytesRead;
var buffer = new byte[resourceStream.Length];
while ((bytesRead = resourceStream.Read(buffer, 0, buffer.Length)) > 0)
fileStream.Write(buffer, 0, bytesRead);
}
}
示例8: getThumbnail
private BitmapImage getThumbnail(string file, IsolatedStorageFile iso)
{
BitmapImage bmp = new BitmapImage();
if (iso.FileExists(file))
{
using (IsolatedStorageFileStream stream = iso.OpenFile(file, FileMode.Open, FileAccess.Read))
{
bmp.SetSource(stream);
}
}
else
bmp = null;
return bmp;
}
示例9: ScoreManager
private ScoreManager()
{
CurrentScore = 0;
BestScore = 0;
#if WINDOWS_PHONE
savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (savegameStorage.FileExists(filename) == false)
{
CreateSaveFile();
}
else
{
LoadLastSave();
}
#endif
}
示例10: Configure
/// <summary>
/// Configures the diagnostic log
/// </summary>
/// <param name="fileName"></param>
/// <param name="enable"> </param>
public static void Configure(string fileName, bool enable) {
try {
_IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
_FileName = fileName;
#if DEBUG
if (_IsolatedStorage.FileExists(_FileName)) {
_IsolatedStorage.DeleteFile(_FileName);
}
#endif
IsEnabled = enable;
if (enable) {
WriteLogFileHeader();
}
} catch (Exception ex) {
Debug.WriteLine(ex.ToString());
}
}
示例11: 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;
}
}
示例12: GetAvailableSpace
private static long GetAvailableSpace(string xapName, IsolatedStorageFile iso)
{
var availableSpace = iso.AvailableFreeSpace;
if (iso.FileExists(xapName))
{
using (var file = iso.OpenFile(xapName, FileMode.Open))
{
availableSpace += file.Length;
}
}
return availableSpace;
}
示例13: Rename
/// <summary>
/// Changes the name of this savegame.
/// </summary>
/// <param name="tag"></param>
/// <param name="name"></param>
public void Rename(CartridgeTag tag, string name, IsolatedStorageFile isf)
{
string oldGwsFile = SavegameFile;
string oldMdFile = MetadataFile;
// Changes the properties.
Name = name;
SetFileProperties(tag);
// Renames the files.
if (isf.FileExists(oldGwsFile))
{
isf.MoveFile(oldGwsFile, SavegameFile);
}
if (isf.FileExists(oldMdFile))
{
isf.MoveFile(oldMdFile, MetadataFile);
}
}
示例14: DeleteFileHelper
private static void DeleteFileHelper(IsolatedStorageFile isoStore, string path)
{
int retries = 3;
while (retries-- > 0)
{
try
{
if (isoStore.FileExists(path))
{
isoStore.DeleteFile(path);
}
else
{
return;
}
}
catch (IsolatedStorageException)
{
// random iso-store failures..
//
Thread.Sleep(50);
}
return;
}
}
示例15: GetSavedPassword
/// <summary>
/// Gets the saved password.
/// </summary>
/// <returns></returns>
private static DbPersistentData GetSavedPassword(
IsolatedStorageFile store, string protectPath,
string parsedXmlPath, string masterPassPath)
{
var result = new DbPersistentData();
if (!store.FileExists(protectPath))
{
throw new FileNotFoundException(protectPath);
}
if (!store.FileExists(parsedXmlPath))
{
throw new FileNotFoundException(parsedXmlPath);
}
if (!store.FileExists(masterPassPath))
{
throw new FileNotFoundException(masterPassPath);
}
using (var fs = store.OpenFile(protectPath, FileMode.Open))
using (var buffer = new MemoryStream((int)fs.Length))
{
BufferEx.CopyStream(fs, buffer);
result.Protection = buffer.ToArray();
}
using (var fs = store.OpenFile(parsedXmlPath, FileMode.Open))
using (var buffer = new MemoryStream((int)fs.Length))
{
BufferEx.CopyStream(fs, buffer);
result.Xml = buffer.ToArray();
}
using (var fs = store.OpenFile(masterPassPath, FileMode.Open))
using (var buffer = new MemoryStream((int)fs.Length))
{
BufferEx.CopyStream(fs, buffer);
result.MasterKey = buffer.ToArray();
}
return result;
}