Even when my app closes and finishes, when I watch on my task manager -> processes, there are many excel processes which even prevent my computer from shutting down.
Here is my code:
private void write_data_to_excel(byte[] input)
{
FileStream f = File.OpenWrite("StocksData.xls");
f.Write(input, 0, input.Length);
f.Close();
}
Another possible method who causes this:
private void get_stocks_data()
{
byte[] result;
byte[] buffer = new byte[4096];
try
{
WebRequest wr = WebRequest.Create("http://www.tase.co.il/TASE/Pages/ExcelExport.aspx?sn=none&enumTblType=allShares&Columns=noneColumns&Titles=noneTitles&action=1&SubAction=0&GridId=33&CurGuid={0BDA5110-EF93-44CB-A0F0-468C6F502B51}&ExportType=1");
using (WebResponse response = wr.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (MemoryStream memoryStream = new MemoryStream())
{
int count = 0;
do
{
count = responseStream.Read(buffer, 0, buffer.Length);
memoryStream.Write(buffer, 0, count);
} while (count != 0);
result = memoryStream.ToArray();
write_data_to_excel(result);
}
}
}
}
My code also contains:
xlApp = new Excel.Application();
xlWorkBook = xlApp.Workbooks.Open(file, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
These methods are called priodicly... What am I not closing or...?