On Tue, 26 Aug 2008 03:21:20 -0700, macneed <ma*****@yahoo.com.hkwrote:
Can i lock a file in c#,
that i can move it and del it,
but other program don't have right to access(read) until i release it?
i read fileshare.none, but can't delete it without close the filestream
or
streamwriter
there was still a cocurrency problem if i close the stream and delete it
just after close
what can i do?
As far as I know, nothing. The file API just doesn't work that way. You
can assert exclusive access only while you have the file open, and you can
move or delete the file only while the file _isn't_ open.
If you want your application to have exclusive move and delete rights for
the file, you need to do that at the file security attributes level. Your
application would have to run as a user that is exclusively granted those
rights in the file's access control list.
Pete