Whats wrong with my backgroundwork method
- by diver-d
I am trying to get a background worker process working in a wpf application. it creates 2 files then crashes.
   BackgroundWorker worker = new BackgroundWorker();
                        worker.DoWork += delegate(object s, DoWorkEventArgs args)
                        {
                            CreateFile(i.ToString());
                        };
                        worker.RunWorkerAsync();
private void CreateFile(string fileName)
    {
        string path = string.Format(@"{0}\{1}.txt", directory, fileName);
        using (StreamWriter sw = new StreamWriter(path))
        {
            sw.WriteLine(fileName);
        }
    }
I get this error "
The requested operation cannot be performed on a file with a user-mapped section open." what am I doing wrong?
Any help would be great