Esempio n. 1
0
 public void Dispose()
 {
     if (FileStreamWriter != null)
     {
         FileStreamWriter.Flush();
         FileStreamWriter.Dispose();
         Filename         = null;
         FileStreamWriter = null;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 释放资源
        /// </summary>
        public void Dispose()
        {
            isDisposed = true;
            if (Interlocked.CompareExchange(ref isPushFiles, 0, 1) == 1)
            {
                Files.PopNotNull(this);
                Flush();
                AutoCSer.DomainUnload.Unloader.RemoveLast(this, DomainUnload.Type.LogFileDispose, false);
                if (Pub.Log != this || AutoCSer.DomainUnload.Unloader.State != DomainUnload.State.Run)
                {
#if XAMARIN
                    if (fileStream != null)
                    {
                        fileStream.Dispose();
                        fileStream = null;
                    }
#else
                    if (fileStream != null)
                    {
                        if (fileStream.NewLength == 0)
                        {
                            fileStream.Dispose();
                            fileStream = null;
                        }
                        else
                        {
                            string fileName = fileStream.FileName;
                            fileStream.Dispose();
                            fileStream = null;
                            AutoCSer.IO.File.MoveBak(fileName);
                        }
                    }
#endif
                }
            }
        }