Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / Delphi - Check if File Opened?

Author
Message
Sergey K
21
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 4th Mar 2006 20:25
hey all, i got a questions; how do i check if the file is opened by other program?

empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Mar 2006 22:52
You could try to open the file and check if an error returns.


That'd only work if the file isn't open in shared mode, though.

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 5th Mar 2006 23:02
Delphi looks like dbp syntax

Sergey K
21
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 6th Mar 2006 12:46
humm.. i could try to use Try/except commands to check if file is already in use
like:


end;

is that will work?


btw, empty, what with the {$I-} and {$I+} commands?
what they are for?

Paisleys finest
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: In a house
Posted: 6th Mar 2006 13:26
{$I} enables/disables I/O checking code.

If you disable I/O checking then an exception will not be thrown by your program if a file cannot be opened. Instead you use IOResult to determine if the file open was successful.

Check the IOResult docs in Delphi and you'll see more about {$I} compiler directive

Regards, Scott T.

Looking for mature software developer to finish my Bruce Lee remake.. apply via email to MSN address.
Sergey K
21
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 6th Mar 2006 15:23
humm.. nice.. really need to learn more about the delphi.. cuz it sounds v. powerful from what i have imagine

hyrichter
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 6th Mar 2006 16:30
If it's possible, it's possible with Delphi (and usually quite simple, too!).

Login to post a reply

Server time is: 2025-06-17 07:05:24
Your offset time is: 2025-06-17 07:05:24