republican-creole
Search:  

 
 
   All ForumsHot TopicsGallery






how-to block ads


 
Forums » Tech and Talk » OS and Software » Webmasters and Developers » VBScript - test if text file is in use
Search Topic:
Uniqs:
1749
Share Topic:
RSS topic:
toggle:
flat / full
normal / watch
Posting:
Post a:
Post a:
Null Vs. Empty »
« Proxy Rewrite to have main site subdir retrieve from 2nd svr  
AuthorAll Replies


DFWDraco76
Premium
join:2001-02-21
Plano, TX
clubs:
·Verizon FIOS

VBScript - test if text file is in use

I'm working on something where there is a chance a text file I need to open/modify in vbscript might already be in use... so I'm trying to figure out a way to test if that's the case.

this does not seem to work for text files...

Any other ideas? I could test the LastModified property, but if the file was just opened would that reflect anything? (i.e. it only updates when the file is saved, right?)

I tried the "openfiles" command but again, it doesn't reflect anything about text files. (note the given url is for xp, but the parameters are much more limited on server 2k3)
--
»blog.thelifeofbrian.info


PapaDos
Cum Grano Salis
Premium,MVM
join:2001-02-08
Lasalle, QC
There is nothing special about "text files", they are just files. The problem might be your definition of "in use" ?
--
Festina Lente


cowboyro

join:2000-10-11
Shelton, CT
reply to DFWDraco76
I assume "in use" means open for write. Easiest would be to try to open it for write and catch the error if any.


PToN

join:2001-10-04
Houston, TX

said by cowboyro See Profile :

I assume "in use" means open for write. Easiest would be to try to open it for write and catch the error if any.
It depends. Since you can open a file with notepad multiple times without getting an error.. So Your method doesnt apply for every scenario.


PetePuma
How many lumps do you want
Premium,MVM
join:2002-06-13
Arlington, VA
reply to DFWDraco76
What happens if you try calling OpenTextFile with "forWriting" and the create flag = false?

"In use" is kind of squishy. It depends on how the file was opened by the other user/application as to whether or not the OS will let you open it.


DFWDraco76
Premium
join:2001-02-21
Plano, TX
clubs:
·Verizon FIOS

reply to DFWDraco76
Thanks for the responses! Unfortunately other fires came up today and I haven't even had time (since posting) to think about this.

I'll follow up when I'm able to get back around to it...
--
»blog.thelifeofbrian.info


cowboyro

join:2000-10-11
Shelton, CT
reply to PToN
Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]
You can always open the file with a lock


DFWDraco76
Premium
join:2001-02-21
Plano, TX
clubs:
·Verizon FIOS

said by cowboyro See Profile :

Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]
You can always open the file with a lock
Sorry I don't understand - can you explain how to lock the file more clearly? You're talking about vbscript, right?
--
»blog.thelifeofbrian.info


DFWDraco76
Premium
join:2001-02-21
Plano, TX
clubs:
·Verizon FIOS

just getting back to this....

came up with a simple kludge/workaround:
* when a change needs to be made to the file, copy filename.txt to filename.txt.inuse and delete filename.txt
* make whatever changes are necessary
* when done, copy filename.txt.inuse back to filename.txt and delete the .inuse version

For the "clients" needing to modify the file:
* check for existence of the .inuse file; if it's there, sleep x seconds, else follow the algorithm above.

I think that will work for us...
--
»blog.thelifeofbrian.info
-
Forums » Tech and Talk » OS and Software » Webmasters and DevelopersNull Vs. Empty »
« Proxy Rewrite to have main site subdir retrieve from 2nd svr  


Sunday, 29-Nov 05:39:17 Terms of Use | Privacy Policy | Hosting by www.nac.net - DSL,Hosting & Co-lo | feedback | contact
over 10 years online! © 1999-2009 dslreports.com.
page compression OFF
Most commented news this week
· [122] Time Warner Cable Fires Broadside At Broadcasters
· [112] New AT&T Ad Campaign Hits Back At Verizon
· [96] Apple Joins AT&T Verizon Snark Fest
· [87] New Bill Takes Aim At Higher Verizon ETFs
· [80] TiVo Sees Record Customer Losses
· [73] Weekend Open Thread
· [72] Verizon CEO: Hulu Will Be Dead Soon
· [69] In-Flight Internet Headed For Bumpy Landing?
· [62] Thanksgiving Open Thread
· [40] EFF Wages War On Fine Print
Most people now reading
· ToC 4th boss - Preliminary Strategy for Twin Valkyr [World of Warcraft]
· AV-Comp. Retrospective/Proactive Test 11/2009 released [Security]
· Windows 7 boot manager editing questions [Microsoft Help]
· [FREEZING] Spybost S&D Updater [Security]
· Anyone have a problem [Software]
· Evading throttling with uTP / uTorrent 1.9a [TekSavvy]
· [WIN7] Let's See Your Win 7 Desktop [Microsoft Help]
· 3.x Feral Druid - Bear Tanking Guide [World of Warcraft]
· [Newsgroups] Newzleech down? [Filesharing Software]
· Security Software Updates - 28 Nov 2009 [Security]