setting folder/file access after creation
-
hi. I am creating a folder and writing files to it in code. After the file is created, it emails it. After emailing i want to delete it off the sever's disk. I get the following error after i create the file
The process cannot access the file 'C:\\pdfConversion\\SpiderSearchReport_DAY COLIN ANTHONY.PDF' because it is being used by another process."
I am not using response object to write the file. The file is closed after creation. Can anyone help me to set the file 2 be able to be deleted after? Thanks. -
hi. I am creating a folder and writing files to it in code. After the file is created, it emails it. After emailing i want to delete it off the sever's disk. I get the following error after i create the file
The process cannot access the file 'C:\\pdfConversion\\SpiderSearchReport_DAY COLIN ANTHONY.PDF' because it is being used by another process."
I am not using response object to write the file. The file is closed after creation. Can anyone help me to set the file 2 be able to be deleted after? Thanks.My guess is that your own process still has the file handle opened. So make sure that you close the File(Stream?). Best practice is to surround the FileStream with an using(...){} - so you make sure that Dispose is called and the handle is freed. If you forget this you will have to wait till the GC kicks in and frees the object for you (or till you close the process)
-
My guess is that your own process still has the file handle opened. So make sure that you close the File(Stream?). Best practice is to surround the FileStream with an using(...){} - so you make sure that Dispose is called and the handle is freed. If you forget this you will have to wait till the GC kicks in and frees the object for you (or till you close the process)
-
My guess is that your own process still has the file handle opened. So make sure that you close the File(Stream?). Best practice is to surround the FileStream with an using(...){} - so you make sure that Dispose is called and the handle is freed. If you forget this you will have to wait till the GC kicks in and frees the object for you (or till you close the process)