remove file access denied

Norm norm.rowtree at gmail.com
Fri Sep 14 04:48:09 UTC 2018


On Thursday, 13 September 2018 at 23:25:24 UTC, Josphe Brigmo 
wrote:
> I am trying to remove a file
>
> remove(filename);
>
> and I get an access denied!
>
> I can remove it from explorer just fine.
>
> I am able to remove other files but there should be no reason 
> why the file can't be removed in this case.
>
> All I am doing to mess with the file is reading it's contents 
> right before to do a file compare(I am removing the file if it 
> is a duplicate).
>
> Does read() lock the file at all? (maybe the lock is persisting 
> just long enough to make the remove fail?
>
> Since I can delete the file outside the program and since the 
> filename is valid(I copied and pasted it to remove it to 
> check), This seems like a D problem.

Do you have the file open when you call remove? If so close the 
file handle before the remove call. If you can post a stripped 
down version of your code it would also help.

bye,
Norm


More information about the Digitalmars-d-learn mailing list