create a new file with exclusive owner mode
Hello everyone,
I did some research for File.Create API to find some option which could be used to create a new file, with exclusive owner mode (e.g. other process/thread can not delete/open/modify when current thread keep the file open). But can not find it out.
Could anyone let me know which option should I use or which API should I use?
thanks in advance,
George
Re: create a new file with exclusive owner mode
Should look at the "lock" statement.
Re: create a new file with exclusive owner mode
Thanks mariocatch,
I am confused. Could you provide a link please? Which API do you mean?
Quote:
Originally Posted by mariocatch
Should look at the "lock" statement.
regards,
George
Re: create a new file with exclusive owner mode
type "lock" into your IDE and press F1. Or do an MSDN search for "lock".
Re: create a new file with exclusive owner mode
Thanks mariocatch,
But lock does not provide cross-process exclusive control, right?
Quote:
Originally Posted by mariocatch
type "lock" into your IDE and press F1. Or do an MSDN search for "lock".
regards,
George
Re: create a new file with exclusive owner mode
Look at the FileShare enumeration used by the FileStream class.
Another option is to use a named mutex and have each process lock/unlock the mutex.