Opening File that is already exclusively opened
-
Hi Guys, As i was working i got a problem. as i have to open a file, i simply call CreateFile and it Opens it. now if some application like MS Excel ect have open it previously, it is not letting me open the file.. now if it is about sharing voilation, how notepad manages the file to open it?? i think i am clear to whar i require Expecting some Quick responce..
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi Guys, As i was working i got a problem. as i have to open a file, i simply call CreateFile and it Opens it. now if some application like MS Excel ect have open it previously, it is not letting me open the file.. now if it is about sharing voilation, how notepad manages the file to open it?? i think i am clear to whar i require Expecting some Quick responce..
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
My guess is that Notepad opens the file for reading only (and only tries to open it for writing if the user wants to save, at which point it will also fail), when Excel or Word or the likes opens the file it probably allows other processes to read the file, but not to write to them (this would explain how you get a "open for reading only" option from Word if you try to open a document that is opened by another word instance/another user's word...). Can it be that when you use CreateFile to open the file you try to open it for writing?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <