473,749 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check if file is open

jes
hi,

i have an open & delete btn. onclick of open as visio drawing opens in visio
& onclick of delete the drawing gets deleted from the filesystem. The problem
is i am unable to perform these actions if the file is already opened in
another instance of visio. how do i check if it's already opened and then
throw an error msg?

thanks
Dec 6 '05 #1
4 3015
Hi Dear jes

check this

http://msdn.microsoft.com/library/de...classtopic.asp

bye
Venkat_KL
Dec 6 '05 #2
Use Try/Catch.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"jes" <je*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
hi,

i have an open & delete btn. onclick of open as visio drawing opens in
visio
& onclick of delete the drawing gets deleted from the filesystem. The
problem
is i am unable to perform these actions if the file is already opened in
another instance of visio. how do i check if it's already opened and then
throw an error msg?

thanks

Dec 6 '05 #3
jes
Hi,

I am not using the filestream to open the file, i am using visio's object to
open the file. Do u think the try/catch would be the only resolution to check
if the file is already opened?

If File.Exists(fil ename) Then
visioApp = CreateObject("v isio.applicatio n")
visioDocs = visioApp.Docume nts
visioDoc = visioDocs.OpenE x(filename, 32)
end if

thanks

"Kevin Spencer" wrote:
Use Try/Catch.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"jes" <je*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
hi,

i have an open & delete btn. onclick of open as visio drawing opens in
visio
& onclick of delete the drawing gets deleted from the filesystem. The
problem
is i am unable to perform these actions if the file is already opened in
another instance of visio. how do i check if it's already opened and then
throw an error msg?

thanks


Dec 6 '05 #4
Hi jes,

There are other ways to see if the file is already opened, but none of them
are pretty. This is one case where catching an exception is a good idea.

You can read more about the way to do this here:

http://msdn.microsoft.com/library/de...Exceptions.asp
http://msdn.microsoft.com/library/de...exceptions.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"jes" <je*@discussion s.microsoft.com > wrote in message
news:F0******** *************** ***********@mic rosoft.com...
Hi,

I am not using the filestream to open the file, i am using visio's object
to
open the file. Do u think the try/catch would be the only resolution to
check
if the file is already opened?

If File.Exists(fil ename) Then
visioApp = CreateObject("v isio.applicatio n")
visioDocs = visioApp.Docume nts
visioDoc = visioDocs.OpenE x(filename, 32)
end if

thanks

"Kevin Spencer" wrote:
Use Try/Catch.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"jes" <je*@discussion s.microsoft.com > wrote in message
news:9F******** *************** ***********@mic rosoft.com...
> hi,
>
> i have an open & delete btn. onclick of open as visio drawing opens in
> visio
> & onclick of delete the drawing gets deleted from the filesystem. The
> problem
> is i am unable to perform these actions if the file is already opened
> in
> another instance of visio. how do i check if it's already opened and
> then
> throw an error msg?
>
> thanks


Dec 6 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
9113
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts running when the file is not completely
11
3763
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows 2003 Server or ADO or ODBC issue, I am posting this on all of the three newsgroups. That's the setup: Windows 2003 Server with IIS and ASP.NET actiavted Access 2002 mdb file (and yes, proper rights are set on TMP paths and path,
19
32327
by: wetherbean | last post by:
Hi group..I am writing a playlist management protocol where I have a file that holds all the playlists and a file that holds all the songs....before a playlist is created I need to check to see if the playlist file is empty so that I can assign an integer value to a playlist id field if it is the first playlist being written to the file....can anyone help?? Thanks in advance wetherbean
6
55992
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I check if a file is open before deleting it Something like this
9
4321
by: Dino Buljubasic | last post by:
If I want to delete a file I can call File.Delete(filePath) but what happens if I am trying to delete the file that is open??? In java you would do someting like int status = fileExists(filePath) // return 0, 1, or 2 2 means file exists and it si open but VB returns boolean value telling file exist or not
5
20279
by: cmay | last post by:
The only examples I have seen on how to check if a file is locked is to try to open it a catch an exception. MS has stated that you should never use error trapping in this manner. Is there no other way to identify if a file is locked w/o trapping an exception?
6
34649
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case I would ignore processing that particular file and move to next file. How can I check whether the file is open or not? I tried os.stat and os.access but I am not getting the expected results. Also I checked in IO exceptions, IO error handler...
4
2648
by: giftson.john | last post by:
Hi, I am creating an application which migrates all documents from one repository to another repository. Before migration i have to verify all the documents are unique. No duplicates has to be uploaded. Event the document created date, modified date, filename can be different. How to find the document is duplidate. What i did is, i created a file and did save as and saved into another location. I am not able to find that the document...
2
13408
by: Kimmo Laine | last post by:
Hi! Is there a way to check if file is already open/used by another process? I know that i can do something like this to check it try { StreamWriter sw = new StreamWriter(filename); sw.Close(); } catch (IOException) {
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.