Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 17th, 2005, 09:15 PM
Jason Charalambides
Guest
 
Posts: n/a
Default 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.


  #2  
Old July 17th, 2005, 09:15 PM
Randy Birch
Guest
 
Posts: n/a
Default Re: Tracing a temporary file "If it Exists".

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" <dartgameplayer@netscape.com> wrote in message
news:efkqb.12654$Mc.4342@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.
:
:


  #3  
Old July 17th, 2005, 09:15 PM
Mauro
Guest
 
Posts: n/a
Default Re: Tracing a temporary file "If it Exists".

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


Mauro


"Jason Charalambides" <dartgameplayer@netscape.com> wrote in message
news:efkqb.12654$Mc.4342@twister.austin.rr.com...[color=blue]
> I set a program to automatically load values from a temporary file.
> However, there is a chance that the specific temporary file[/color]
"C:\Temp\TU.tmp"[color=blue]
> 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[/color]
by[color=blue]
> 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.
>
>[/color]


  #4  
Old July 17th, 2005, 09:15 PM
R.Wieser
Guest
 
Posts: n/a
Default Re: Tracing a temporary file "If it Exists".

Mauro <mbiefeni@hotmail.com> schreef in berichtnieuws
XmAqb.324206$6C4.65024@pd7tw1no...
[color=blue]
> If Dir("C:\Temp\TU.tmp")<>"" then
> 'Stuff to do
> End If[/color]

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



  #5  
Old July 17th, 2005, 09:15 PM
Bert Byfield
Guest
 
Posts: n/a
Default Re: Tracing a temporary file "If it Exists".

>> I set a program to automatically load values from a temporary file.[color=blue][color=green]
>> However, there is a chance that the specific temporary file[/color]
> "C:\Temp\TU.tmp"[color=green]
>> may not exist at all. In that case I want that specific routine to
>> be skipped. I guess this is a simple[/color][/color]
[color=blue]
> If Dir("C:\Temp\TU.tmp")<>"" then
> 'Stuff to do
> End If
> Mauro[/color]

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.




  #6  
Old July 17th, 2005, 09:15 PM
Jim SUTTON
Guest
 
Posts: n/a
Default Re: Tracing a temporary file "If it Exists".


"Jason Charalambides" <dartgameplayer@netscape.com> wrote in message
news:efkqb.12654$Mc.4342@twister.austin.rr.com...[color=blue]
> I set a program to automatically load values from a temporary file.
> However, there is a chance that the specific temporary file[/color]
"C:\Temp\TU.tmp"[color=blue]
> 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[/color]
by[color=blue]
> 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.
>
>[/color]

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.


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles