Inheritance: MarshalByRefObject
        public override void SetLength(long value)
        {
            container.PreCheck();
            // don't worry about quota if we can't write to the stream,
            // the base class will throw the expected NotSupportedException
            if (!base.CanWrite)
            {
                return;
            }

            // will that request put us in a position to grow *or shrink* the file ?
            // note: this can be negative, e.g. calling SetLength(0), so we can't call EnsureQuotaLimits directly
            if (!IsolatedStorage.CanExtend(value - Length))
            {
                throw new IsolatedStorageException("Requested size is larger than remaining quota allowance.");
            }

            base.SetLength(value);
        }
        private void EnsureQuotaLimits(long request)
        {
            // don't worry about quota if we can't write to the stream,
            // the base class will throw the expected NotSupportedException
            if (!base.CanWrite)
            {
                return;
            }

            // will that request put us in a position to grow the file ?
            long grow = Position + request - Length;

            if (grow < 0)
            {
                return;
            }

            if (!IsolatedStorage.CanExtend(grow))
            {
                throw new IsolatedStorageException("Requested size is larger than remaining quota allowance.");
            }
        }
Exemplo n.º 3
0
        public bool MoveNext()
        {
            IsolatedStorageFile  isf;
            IsolatedStorageScope scope;
            bool     fApp;
            TwoPaths tp;
            Stream   app, assem;
            String   appName, assemName;

            m_fiop.Assert();

            m_fReset = false;

            do
            {
                if (m_fileEnum.MoveNext() == false)
                {
                    m_fEnd = true;
                    break;
                }

                // Create the store
                isf = new IsolatedStorageFile();

                tp   = (TwoPaths)m_fileEnum.Current;
                fApp = false;

#if _DEBUG
                if (s_fDebug)
                {
                    Console.Write(tp.Path1 + " ");
                    Console.WriteLine(tp.Path2);
                }
#endif

                if (IsolatedStorageFile.NotAssemFilesDir(tp.Path2))
                {
                    fApp = true;
                }

                // Create Roaming Store
                app   = null;
                assem = null;

                if (fApp)
                {
                    if (!GetIDStream(tp.Path1, out app))
                    {
                        continue;
                    }

                    if (!GetIDStream(tp.Path1 + s_SepExternal + tp.Path2,
                                     out assem))
                    {
                        continue;
                    }

                    app.Position = 0;

                    if (IsolatedStorage.IsRoaming(m_Scope))
                    {
                        scope = IsolatedStorage.c_AppRoaming;
                    }
                    else
                    {
                        scope = IsolatedStorage.c_App;
                    }

                    appName   = tp.Path1;
                    assemName = tp.Path2;
                }
                else
                {
                    if (!GetIDStream(tp.Path1, out assem))
                    {
                        continue;
                    }

                    if (IsolatedStorage.IsRoaming(m_Scope))
                    {
                        scope = IsolatedStorage.c_AssemblyRoaming;
                    }
                    else
                    {
                        scope = IsolatedStorage.c_Assembly;
                    }

                    appName   = null;
                    assemName = tp.Path1;
                }

                assem.Position = 0;

                if (!isf.InitStore(scope, app, assem, appName, assemName))
                {
                    continue;
                }

                if (!isf.InitExistingStore(scope))
                {
                    continue;
                }

                m_Current = isf;

                return(true);
            } while (true);

            return(false);
        }
Exemplo n.º 4
0
 public void Remove()
 {
     PreCheck();
     IsolatedStorage.Remove(basedir);
     removed = true;
 }
Exemplo n.º 5
0
 public bool MoveNext()
 {
     this.m_fiop.Assert();
     this.m_fReset = false;
     while (this.m_fileEnum.MoveNext())
     {
         IsolatedStorageFile isolatedStorageFile = new IsolatedStorageFile();
         TwoPaths            twoPaths            = (TwoPaths)this.m_fileEnum.Current;
         bool flag = false;
         if (IsolatedStorageFile.NotAssemFilesDir(twoPaths.Path2) && IsolatedStorageFile.NotAppFilesDir(twoPaths.Path2))
         {
             flag = true;
         }
         Stream stream  = null;
         Stream stream2 = null;
         Stream stream3 = null;
         IsolatedStorageScope scope;
         string domainName;
         string assemName;
         string appName;
         if (flag)
         {
             if (!this.GetIDStream(twoPaths.Path1, out stream) || !this.GetIDStream(twoPaths.Path1 + "\\" + twoPaths.Path2, out stream2))
             {
                 continue;
             }
             stream.Position = 0L;
             if (IsolatedStorage.IsRoaming(this.m_Scope))
             {
                 scope = (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.Roaming);
             }
             else if (IsolatedStorage.IsMachine(this.m_Scope))
             {
                 scope = (IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly | IsolatedStorageScope.Machine);
             }
             else
             {
                 scope = (IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly);
             }
             domainName = twoPaths.Path1;
             assemName  = twoPaths.Path2;
             appName    = null;
         }
         else if (IsolatedStorageFile.NotAppFilesDir(twoPaths.Path2))
         {
             if (!this.GetIDStream(twoPaths.Path1, out stream2))
             {
                 continue;
             }
             if (IsolatedStorage.IsRoaming(this.m_Scope))
             {
                 scope = (IsolatedStorageScope.User | IsolatedStorageScope.Assembly | IsolatedStorageScope.Roaming);
             }
             else if (IsolatedStorage.IsMachine(this.m_Scope))
             {
                 scope = (IsolatedStorageScope.Assembly | IsolatedStorageScope.Machine);
             }
             else
             {
                 scope = (IsolatedStorageScope.User | IsolatedStorageScope.Assembly);
             }
             domainName       = null;
             assemName        = twoPaths.Path1;
             appName          = null;
             stream2.Position = 0L;
         }
         else
         {
             if (!this.GetIDStream(twoPaths.Path1, out stream3))
             {
                 continue;
             }
             if (IsolatedStorage.IsRoaming(this.m_Scope))
             {
                 scope = (IsolatedStorageScope.User | IsolatedStorageScope.Roaming | IsolatedStorageScope.Application);
             }
             else if (IsolatedStorage.IsMachine(this.m_Scope))
             {
                 scope = (IsolatedStorageScope.Machine | IsolatedStorageScope.Application);
             }
             else
             {
                 scope = (IsolatedStorageScope.User | IsolatedStorageScope.Application);
             }
             domainName       = null;
             assemName        = null;
             appName          = twoPaths.Path1;
             stream3.Position = 0L;
         }
         if (isolatedStorageFile.InitStore(scope, stream, stream2, stream3, domainName, assemName, appName) && isolatedStorageFile.InitExistingStore(scope))
         {
             this.m_Current = isolatedStorageFile;
             return(true);
         }
     }
     this.m_fEnd = true;
     return(false);
 }