当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageFile.FileExists方法代码示例

本文整理汇总了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;
        }
开发者ID:kamaelyoung,项目名称:WF.Player.WinPhone,代码行数:38,代码来源:CartridgeSavegame.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();
        }
开发者ID:AndreaBruno,项目名称:Macchinino,代码行数:25,代码来源:Accelerometro.xaml.cs

示例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);
 	}
开发者ID:Galigator,项目名称:db4o,代码行数:8,代码来源:IsolatedStorageFileBin.cs

示例4: MainPage

        public MainPage()
        {
            InitializeComponent();

            myFile = IsolatedStorageFile.GetUserStoreForApplication();

            if (!myFile.FileExists("Impo.txt"))
            {
                IsolatedStorageFileStream dataFile = myFile.CreateFile("Impo.txt");
                dataFile.Close();
            }
        }
开发者ID:AndreaBruno,项目名称:Macchinino,代码行数:12,代码来源:MainPage.xaml.cs

示例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 );
         }
     }
 }
开发者ID:arakuma,项目名称:wp_imagetool,代码行数:18,代码来源:FsBitmapCache.cs

示例6: SafeDeleteFile

 public static void SafeDeleteFile(IsolatedStorageFile storage, string fileName)
 {
     try
     {
         if (storage.FileExists(fileName))
         {
             storage.DeleteFile(fileName);
         }
     }
     catch (Exception)
     {
     }
 }
开发者ID:kyvok,项目名称:TransitWP7,代码行数:13,代码来源:IsolatedStorageHelper.cs

示例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);
            }
        }
开发者ID:jonnohuang,项目名称:projects,代码行数:14,代码来源:MainPage.xaml.cs

示例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;
        }
开发者ID:UWbadgers16,项目名称:PhotoEnhancement,代码行数:16,代码来源:AllPhotos.xaml.cs

示例9: ScoreManager

        private ScoreManager()
        {
            CurrentScore = 0;
            BestScore = 0;

            #if WINDOWS_PHONE
            savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();

            if (savegameStorage.FileExists(filename) == false)
            {
                CreateSaveFile();
            }
            else
            {
                LoadLastSave();
            }
            #endif
        }
开发者ID:patrickzip,项目名称:fries-and-furious,代码行数:18,代码来源:ScoreManager.cs

示例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());
            }
        }
开发者ID:Sebazzz,项目名称:SDammann.WindowsPhone.Utils,代码行数:25,代码来源:DiagnosticHelper.cs

示例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;
            }
        }
开发者ID:SNSB,项目名称:DiversityMobile,代码行数:38,代码来源:LogFile.cs

示例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;
        }
开发者ID:mparsin,项目名称:Elements,代码行数:14,代码来源:DownloadCache.cs

示例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);
            }
        }
开发者ID:chier01,项目名称:WF.Player.WinPhone,代码行数:24,代码来源:CartridgeSavegame.cs

示例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;
            }
        }
开发者ID:sawilde,项目名称:AgFx,代码行数:26,代码来源:IsoStoreProvider.cs

示例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;
        }
开发者ID:gkardava,项目名称:WinPass,代码行数:44,代码来源:DatabaseInfo.cs


注:本文中的System.IO.IsolatedStorage.IsolatedStorageFile.FileExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。