System.IO.FileStream.Flush C# (CSharp) Method

Flush() public method

Clears buffers for this stream and causes any buffered data to be written to the file.
public Flush ( ) : void
return void
        public override void Flush()
        {
            // Make sure that we call through the public virtual API
            Flush(flushToDisk: false);
        }

Same methods

FileStream::Flush ( bool flushToDisk ) : void

Usage Example

Example #1
1
        //Đưa SecretKey vào File của thuật toán 3DES
        public void AddSecretKeytoFile(string inputFile)
        {
            //Add SecretKey to File;
            if (File.Exists(inputFile))
            {
                FileStream fsOpen = new FileStream(inputFile, FileMode.Open, FileAccess.ReadWrite);
                try
                {
                    byte[] content = new byte[fsOpen.Length];
                    fsOpen.Read(content, 0, content.Length);
                    //string sContent = System.Text.Encoding.UTF8.GetString(content); //noi dung bang string

                    //byte[] plainbytesCheck = System.Text.Encoding.UTF8.GetBytes(sContent);
                    byte[] plainbytesKey = new UTF8Encoding(true).GetBytes(m_EncryptedSecretKey + "\r\n");

                    fsOpen.Seek(0, SeekOrigin.Begin);
                    fsOpen.Write(plainbytesKey, 0, plainbytesKey.Length);
                    fsOpen.Flush();
                    fsOpen.Write(content, 0, content.Length);
                    fsOpen.Flush();
                    fsOpen.Close();
                }
                catch
                {
                    fsOpen.Close();
                }
            }
        }
All Usage Examples Of System.IO.FileStream::Flush