public void Flush() { try { if (fileStream != null)//possible some files are still pending in Serializer-> like TRansactionHeader, but are closed and not opened again { //streamWriter.FlushAsync().Wait(); stream.Flush(); fileStream.FlushAsync().AsTask().Wait(); } } catch (FileNotFoundException ex)//did not found a better way to check if file exists { } }
public void Flush() { try { if (fileStream != null && !this.IsClosed && isModified) { stream.Flush(); byte[] bytes = stream.ToArray(); fileStream.Seek(0); var streamTemp = fileStream.AsStream(); streamTemp.Write(bytes, 0, bytes.Length); streamTemp.Flush(); fileStream.FlushAsync().AsTask().Wait(); isModified = false; } } catch (FileNotFoundException ex)//did not found a better way to check if file exists { } }