title: how to close File Stream in C#
body: <p>Please see this code.  </p>
  
  <pre><code>string name = dt.Rows[0]["Name"].ToString();
  byte[] documentBytes = (byte[])dt.Rows[0]["DocumentContent"];
  
  int readBytes = 0;
  //int index = 0;
  readBytes = documentBytes.Length;
  try
  {
      using (FileStream fs = new FileStream(name, FileMode.Create, FileAccess.Write, FileShare.Read))
      {
  
          fs.Write(documentBytes, 0, readBytes);
          //System.Diagnostics.Process prc = new System.Diagnostics.Process();
          //prc.StartInfo.FileName = fs.Name;
          Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
          app.Visible = false;
          Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Open(fs.Name);
          Microsoft.Office.Interop.Excel._Worksheet worksheet = (Excel.Worksheet)workbook.Sheets[1]; // Explicit cast is not required here
       //   lastRow = worksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row; 
  
          app.Visible = true;
  
  
          fs.Flush();
          fs.Close();
      }
  }
  catch (Exception ex)
  {
      MessageBox.Show("You have clicked more than one time. File is already open.", "WorkFlow", MessageBoxButtons.OK, MessageBoxIcon.Information);
  }
  </code></pre>
  
  <p>I am opening an excel file using the file stream. Excel is showing up nicely. But I am not able to close file stream. It still comes with a small pop up that shows 'File Now available'. How to get rid of that? I can see fs.Close() and Flush() really not working here. Please help.</p>