469,282 Members | 1,732 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Tracing a temporary file "If it Exists".

I set a program to automatically load values from a temporary file.
However, there is a chance that the specific temporary file "C:\Temp\TU.tmp"
may not exist at all. In that case I want that specific routine to be
skipped. I guess this is a simple

If (that file exists)
Open "C:\Temp\TU.tmp" For Input As #3
etc.......
Else
GoTo
SkipOpeningProcess
End If

and I just define point as "SkipOpeningProcess" and that is fine.
My question is:
What is the command that will trace whether the actual temporary file
exists? If the file does not exist it is perfectly fine to skip this
process as it will be very easy for the traced data to be manually given by
the user.
I assume that's easy but not available in any VB6 book index, ...nor very
easy to find going through pages!
Thank you
J.C.
Jul 17 '05 #1
5 6520
Go to my site and search for FileExists.

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.
"Jason Charalambides" <da************@netscape.com> wrote in message
news:ef*****************@twister.austin.rr.com...
: I set a program to automatically load values from a temporary file.
: However, there is a chance that the specific temporary file
"C:\Temp\TU.tmp"
: may not exist at all. In that case I want that specific routine to be
: skipped. I guess this is a simple
:
: If (that file exists)
: Open "C:\Temp\TU.tmp" For Input As #3
: etc.......
: Else
: GoTo
: SkipOpeningProcess
: End If
:
: and I just define point as "SkipOpeningProcess" and that is fine.
: My question is:
: What is the command that will trace whether the actual temporary file
: exists? If the file does not exist it is perfectly fine to skip this
: process as it will be very easy for the traced data to be manually given
by
: the user.
: I assume that's easy but not available in any VB6 book index, ...nor very
: easy to find going through pages!
: Thank you
: J.C.
:
:
Jul 17 '05 #2
If Dir("C:\Temp\TU.tmp")<>"" then
'Stuff to do
End If
Mauro
"Jason Charalambides" <da************@netscape.com> wrote in message
news:ef*****************@twister.austin.rr.com...
I set a program to automatically load values from a temporary file.
However, there is a chance that the specific temporary file "C:\Temp\TU.tmp" may not exist at all. In that case I want that specific routine to be
skipped. I guess this is a simple

If (that file exists)
Open "C:\Temp\TU.tmp" For Input As #3
etc.......
Else
GoTo
SkipOpeningProcess
End If

and I just define point as "SkipOpeningProcess" and that is fine.
My question is:
What is the command that will trace whether the actual temporary file
exists? If the file does not exist it is perfectly fine to skip this
process as it will be very easy for the traced data to be manually given by the user.
I assume that's easy but not available in any VB6 book index, ...nor very
easy to find going through pages!
Thank you
J.C.

Jul 17 '05 #3
Mauro <mb******@hotmail.com> schreef in berichtnieuws
XmAqb.324206$6C4.65024@pd7tw1no...
If Dir("C:\Temp\TU.tmp")<>"" then
'Stuff to do
End If


But don't try to use this within another loop that uses the "dir" command
.... VB only allowes *one*of those "dir" commands to be active at a time.

Regards,
Rudy Wieser

Jul 17 '05 #4
>> I set a program to automatically load values from a temporary file.
However, there is a chance that the specific temporary file "C:\Temp\TU.tmp"
may not exist at all. In that case I want that specific routine to
be skipped. I guess this is a simple

If Dir("C:\Temp\TU.tmp")<>"" then
'Stuff to do
End If
Mauro


It is not a simple VB6 command, that's why you haven't found it in the
books. You have to have a procedure like the above to do it. This will
work, though in the long run you should avoid "Dir()" and put the
decision in a FUNCTION where you get the attributes or otherwise access
the file and catch any resulting errors, then return true or false:

If FileExists("c:\temp\tu.tmp") then
'do stuff for no file
End If

'where you create "FileExists()" yourself.


Jul 17 '05 #5

"Jason Charalambides" <da************@netscape.com> wrote in message
news:ef*****************@twister.austin.rr.com...
I set a program to automatically load values from a temporary file.
However, there is a chance that the specific temporary file "C:\Temp\TU.tmp" may not exist at all. In that case I want that specific routine to be
skipped. I guess this is a simple

If (that file exists)
Open "C:\Temp\TU.tmp" For Input As #3
etc.......
Else
GoTo
SkipOpeningProcess
End If

and I just define point as "SkipOpeningProcess" and that is fine.
My question is:
What is the command that will trace whether the actual temporary file
exists? If the file does not exist it is perfectly fine to skip this
process as it will be very easy for the traced data to be manually given by the user.
I assume that's easy but not available in any VB6 book index, ...nor very
easy to find going through pages!
Thank you
J.C.


You could add Microsoft Scripting Runtime as a Reference to the project -
this makes available the family of FileSystemObject objects which can do
things like checking whether files and folders exist.

I know some of the chaps on here aren't keen on this, though, and I would be
interested to know why...

Regards

--Jim.
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

40 posts views Thread by Steve Juranich | last post: by
145 posts views Thread by Sidney Cadot | last post: by
2 posts views Thread by Fred | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.