Hi there,

I've created a filw which my system uses to e-mail to users of my system. Below is the code i use to create the file:
Code:
string strVCard = vcg.Generate();
        FileInfo fi = new FileInfo("" + firstn + "" + lastn + "" + ".vcf");
        StreamWriter sw = fi.CreateText();
        sw.Write(strVCard);
        sw.Flush();
        sw.Close();
This is fine but i wish to close the file and delete it after i have e-mailed it. However it won't let me do either as it is being used by another program which is Visual Studio itself. I have tried sw.Dispose() and then fi.Delete() but i was again told that the file was being used by another program.

How do i firstly close it and then delete the file?

Thanks,

Adrian.