protected virtual IsoStoreFileStream GetFileStream(bool create)
        {
            IsolatedStorageFile isoStore = null;

            try
            {
                isoStore = GetIsolatedStorageFile();
            }
            catch (IsolatedStorageException)
            {
                // isolated storage not available, fall back to file.
                //
            }
            catch (ApplicationException)
            {
                // isolated storage not available, fall back to file.
                //
            }

            IsoStoreFileStream isfs = null;

            if (isoStore != null)
            {
                if (isoStore.FileExists("_buddy") || create)
                {
                    var fs = isoStore.OpenFile("_buddy", FileMode.OpenOrCreate);
                    isfs = new IsoStoreFileStream(isoStore, fs);
                }
            }
            else
            {
                // if we didn't get an iso store file back, use a file in the local dir.
                string path = Path.Combine(ExecutionBinDir, "_buddy");

                if (File.Exists(path) || create)
                {
                    var fs = File.Open(path, FileMode.OpenOrCreate);
                    isfs = new IsoStoreFileStream(null, fs);
                }
            }

            return isfs;
        }
Example #2
0
        protected virtual IsoStoreFileStream GetFileStream(bool create)
        {
            IsolatedStorageFile isoStore = null;

            try
            {
                isoStore = GetIsolatedStorageFile();
            }
            catch (IsolatedStorageException)
            {
                // isolated storage not available, fall back to file.
                //
            }
            catch (ApplicationException)
            {
                // isolated storage not available, fall back to file.
                //
            }

            IsoStoreFileStream isfs = null;

            if (isoStore != null)
            {
                if (isoStore.FileExists("_buddy") || create)
                {
                    var fs = isoStore.OpenFile("_buddy", FileMode.OpenOrCreate);
                    isfs = new IsoStoreFileStream(isoStore, fs);
                }
            }
            else
            {
                // if we didn't get an iso store file back, use a file in the local dir.
                string path = Path.Combine(ExecutionBinDir, "_buddy");

                if (File.Exists(path) || create)
                {
                    var fs = File.Open(path, FileMode.OpenOrCreate);
                    isfs = new IsoStoreFileStream(null, fs);
                }
            }

            return(isfs);
        }