當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。