|
Prev: Panel flicker
Next: TextBox KeyPress
From: Denis Correard on 15 Sep 2005 07:43 Is there a way to find out if a file, say a TXT file, is already open by another user/application in VB.net? I tryed to look at "Stream", "FileInfo" but without success. I need to know because in my app I move file from 1 place to another but if the file is in use My app hangup without reporting an error. I use: Dim fi as new fileinfo(strfile) fi.MoveTo(<<destination>>) Can Anyone help? Many thanks Denis
From: tomb on 15 Sep 2005 09:22 I would try just opening the file first - if that doesn't work, then don't try to move it. Tom Denis Correard wrote: >Is there a way to find out if a file, say a TXT file, is already open by >another user/application in VB.net? > >I tryed to look at "Stream", "FileInfo" but without success. > >I need to know because in my app I move file from 1 place to another but if >the file is in use My app hangup without reporting an error. >I use: >Dim fi as new fileinfo(strfile) > >fi.MoveTo(<<destination>>) > >Can Anyone help? > >Many thanks > >Denis > > > >
From: Denis Correard on 15 Sep 2005 09:28 Sound a good Idear but how would you go about opening a file without the associated application like *.doc and word, PDF and adobe reader? "tomb" <tomb(a)technetcenter.com> wrote in message news:ezeWe.6342$%Q1.4583(a)bignews3.bellsouth.net... >I would try just opening the file first - if that doesn't work, then don't >try to move it. > > Tom > > Denis Correard wrote: > >>Is there a way to find out if a file, say a TXT file, is already open by >>another user/application in VB.net? >> >>I tryed to look at "Stream", "FileInfo" but without success. >> >>I need to know because in my app I move file from 1 place to another but >>if the file is in use My app hangup without reporting an error. >>I use: >>Dim fi as new fileinfo(strfile) >> >>fi.MoveTo(<<destination>>) >> >>Can Anyone help? >> >>Many thanks >> >>Denis >> >>
From: Andrew Morton on 15 Sep 2005 12:19 Denis Correard wrote: > Sound a good Idear but how would you go about opening a file without > the associated application like *.doc and word, PDF and adobe reader? You don't need to open the file in that sense, just to open it in the sense that the OS is informed you want to do something with it. From the help for Microsoft.VisualBasic.FileOpen:- ------------------------------------ This code example opens the file in Binary mode for reading; other processes can't read file. FileOpen(1, "TESTFILE", OpenMode.Binary, OpenAccess.Read, _ OpenShare.LockRead) ------------------------------------ So if you use that in a try..catch structure then you should get an exception if your app can't get exclusive access to the file. Andrew
|
Pages: 1 Prev: Panel flicker Next: TextBox KeyPress |