Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Flag or reserve a file

Reply
 
Old 05-04-2009   #1 (permalink)
Gil


 
 

Flag or reserve a file

I have a file watcher that I have written and I need to find a way to
flag or reserve a file as being "watched" so that the same filewatcher
doesn't try to process it again. I would appreciate any ideas of how
to do this.
I have tried renaming the file but if the file is in use via an FTP, I
have to go into a sleep mode until the file is completely transferred
and if the polling interval overlaps, the filewatcher tries to process
the same file again.

Best Regards,
Gil.

My System SpecsSystem Spec
Old 05-04-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Flag or reserve a file


"Gil" <gilbertcardenas@xxxxxx> wrote in message
news:b9e7a01a-db9a-4b56-87d4-b6047fcde7a1@xxxxxx
Quote:

>I have a file watcher that I have written and I need to find a way to
> flag or reserve a file as being "watched" so that the same filewatcher
> doesn't try to process it again. I would appreciate any ideas of how
> to do this.
> I have tried renaming the file but if the file is in use via an FTP, I
> have to go into a sleep mode until the file is completely transferred
> and if the polling interval overlaps, the filewatcher tries to process
> the same file again.
>
> Best Regards,
> Gil.
Let's have a look at your file watcher.


My System SpecsSystem Spec
Old 05-04-2009   #3 (permalink)
Todd Vargo


 
 

Re: Flag or reserve a file

Gil wrote:
Quote:

> I have a file watcher that I have written and I need to find a way to
> flag or reserve a file as being "watched" so that the same filewatcher
> doesn't try to process it again. I would appreciate any ideas of how
> to do this.
> I have tried renaming the file but if the file is in use via an FTP, I
> have to go into a sleep mode until the file is completely transferred
> and if the polling interval overlaps, the filewatcher tries to process
> the same file again.
I agree with foxidrive, we need to see what your code is actually doing. In
the mean time, you could try my IsFileInUse function in your script in a
loop. If file is not in use, simply Exit the loop. You may want to include a
breif Sleep delay to allow the ftp process more cpu cycles.

Dim filespec
filespec = "watchedfile.txt" 'File to check

If IsFileInUse(filespec) Then
MsgBox filespec & " is in use."
Else
MsgBox filespec & " is NOT in use."
End If

Wscript.Quit

Function IsFileInUse(filespec)
Dim fso, f, tmp
Set fso = CreateObject("Scripting.FileSystemObject")
IsFileInUse = False
If (fso.FileExists(filespec)) Then
On Error Resume Next
Set f = fso.OpenTextFile(filespec, 8): f.Close
If Err.Number Then IsFileInUse = True
On Error GoTo 0
End If
End Function

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
QoS Bandwidth Reserve Limit Tutorials
Country Flag General Discussion
WLM miss reply flag Live Mail
Sort by Flag broken Vista mail
Windows Mail and the Little Flag Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46