System.IO.WinRTFileStream.Dispose C# (CSharp) Méthode

Dispose() protected méthode

protected Dispose ( bool disposing ) : void
disposing bool
Résultat void
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                    _innerStream.Dispose();

                if ((_options & FileOptions.DeleteOnClose) != 0 && _file != null)
                {
                    // WinRT doesn't directly support DeleteOnClose but we can mimic it
                    // There are a few reasons that this will fail
                    //   1) the file may not allow delete permissions for the current user
                    //   2) the storage file RCW may have already been disconnected
                    try
                    {
                        _file.DeleteAsync().AsTask().Wait();
                    }
                    catch { }
                }

                _disposed = true;
                _file = null;
            }
            finally
            {
                base.Dispose(disposing);
            }
        }