Can't delete a file after CopyTo

  •  06-24-2008, 12:47 PM

    Can't delete a file after CopyTo

    After uploading I copy the file to a working folder.  If the user cancels out of the page, I need to delete the working file, but it is locked and I can't perform cleanup.
     
    I first used "args.CopyTo(workingfile);"
     
    I've also tried:
     
    System.IO.Stream stream = args.GetStream();
    Bitmap bmp = new Bitmap(stream);
    bmp.Save(workingfile);
    stream.Dispose();

    In both cases I was unable to delete the working file. 
     
    I assume I need to close some resource in order to free the locks on the file, but I don't know what needs to be closed or how to do it.  Any help is appreciated.  Thanks.
     
    jrw
View Complete Thread