FileInfo still locking the file ?

A

Andreas Palm

I need to load a txt file into SQL server, so I have to use a
schema.ini file.
Unfortunately MS decided that in this schema.ini the name of the file
that gets sucked in has to be hardcoded. So I decided to read the file
in an array and then change the first line, write out the rest to a
file again. Now all this works fine, however just after writing this
schema.ini I try to fetch the text file in SQL and now in the
background this schema.ini has to be used. But
it complains that the file is locked by another process. :(

Here is my code

FileInfo t = new FileInfo("schema.ini");
StreamWriter Tex =t.CreateText();
Tex.WriteLine("[" + myDA.inputGrouperFileName.ToString() + "]");

for (int y = 1; y < mystring.Length; y++)
{
Tex.WriteLine(mystring[y].ToString());
}
Tex.Close();

t = null;

I feel that FileInfo is still sitting on the File, however there is no
..close() I could use :(

any idea ?

regards
andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top