Click to See Complete Forum and Search --> : create a new file with exclusive owner mode


George2
April 25th, 2008, 02:17 AM
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

mariocatch
April 27th, 2008, 09:01 PM
Should look at the "lock" statement.

George2
April 27th, 2008, 10:30 PM
Thanks mariocatch,


I am confused. Could you provide a link please? Which API do you mean?

Should look at the "lock" statement.


regards,
George

mariocatch
April 28th, 2008, 10:26 AM
type "lock" into your IDE and press F1. Or do an MSDN search for "lock".

George2
April 29th, 2008, 06:32 AM
Thanks mariocatch,


But lock does not provide cross-process exclusive control, right?

type "lock" into your IDE and press F1. Or do an MSDN search for "lock".


regards,
George

Arjay
April 29th, 2008, 01:40 PM
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.