The StreamReader.Close() command calls the Dispose() command, passing a value of true (the Using() construct does the same thing). I have tried calling Dispose() and while it executed successfully it didn't solve the issue.
The Tread.Sleep is implemented in the staging package, but even after half an hour the file remains locked by DTSDebugHost.exe.
Below you'll find two simplified versions (actual processing of the lines taken out to keep it short) :
private void ProcessTextFile(string FileName)
{
var file = new System.IO.StreamReader(FileName);
int row = 0;
string line;
try
{
while ((line = file.ReadLine()) != null)
{
if(!string.IsNullOrEmpty(line))
{
//line processing & insert into db is done here
}
}
//final db insert
}
catch (Exception e)
{
throw e;
}
finally
{
//also tried file.Dispose(); here
file.Close();
}
}
private void ProcessTextFile(string FileName)
{
int row = 0;
string line;
using (var file = new System.IO.StreamReader(importFullFileName))
{
try
{
while ((line = file.ReadLine()) != null)
{
if(!string.IsNullOrEmpty(line))
{
//line processing & insert into db is done here
}
}
//final db insert
}
catch (Exception e)
{
throw e;
}
}
}