How to Delete a used file in C++?
-
Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh
How about MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT?
-
How about MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT?
I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks
-
I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks
Try
_unlink
«_Superman_» I love work. It gives me something to do between weekends.
-
Try
_unlink
«_Superman_» I love work. It gives me something to do between weekends.
-
I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks
yogeshs wrote:
I used this but it is not working bro.
And did you call
GetLastError()
to find out why?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh
yogeshs wrote:
but how i can delete if it using somewhere in project...
Define using?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Hello Friends I m using remove(filename);but how i can delete if it using somewhere in project means is there any way that if i free that file and do this remove command.Or is there any other method to delete the file? Thanks & Regards Yogesh
I assume "using" means that it's "open"ed and you still want to delete it nonetheless. You could try "ShFileOperation".
This signature was proudly tested on animals.
-
I used this but it is not working bro.Let me explain u in brief.In my application i m creating one file and at some conditions i hv to delete that file and that file is deleting only for the first time means after creation if i dont close the application. If i close the app then reopen then i perform operation of deletion on that file it is not deleting.Thats why i want to know is any way to get then free before deletion?Or any other reason? Thanks
When u create/open the file, try to specify the FILE_SHARE_DELETE parameter.