Tracing a temporary file "If it Exists".

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Charalambides

    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
    SkipOpeningProc ess
    End If

    and I just define point as "SkipOpeningPro cess" 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.


  • Randy Birch

    #2
    Re: Tracing a temporary file "If it Exists".

    Go to my site and search for FileExists.

    --

    Randy Birch
    MVP Visual Basic

    Please respond only to the newsgroups so all can benefit.


    "Jason Charalambides" <dartgameplayer @netscape.com> wrote in message
    news:efkqb.1265 4$Mc.4342@twist er.austin.rr.co m...
    : 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
    : SkipOpeningProc ess
    : End If
    :
    : and I just define point as "SkipOpeningPro cess" 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.
    :
    :


    Comment

    • Mauro

      #3
      Re: Tracing a temporary file &quot;If it Exists&quot;.

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


      Mauro


      "Jason Charalambides" <dartgameplayer @netscape.com> wrote in message
      news:efkqb.1265 4$Mc.4342@twist er.austin.rr.co m...[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
      > SkipOpeningProc ess
      > End If
      >
      > and I just define point as "SkipOpeningPro cess" 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]


      Comment

      • R.Wieser

        #4
        Re: Tracing a temporary file &quot;If it Exists&quot;.

        Mauro <mbiefeni@hotma il.com> schreef in berichtnieuws
        XmAqb.324206$6C 4.65024@pd7tw1n o...
        [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



        Comment

        • Bert Byfield

          #5
          Re: Tracing a temporary file &quot;If it Exists&quot;.

          >> 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.




          Comment

          • Jim SUTTON

            #6
            Re: Tracing a temporary file &quot;If it Exists&quot;.


            "Jason Charalambides" <dartgameplayer @netscape.com> wrote in message
            news:efkqb.1265 4$Mc.4342@twist er.austin.rr.co m...[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
            > SkipOpeningProc ess
            > End If
            >
            > and I just define point as "SkipOpeningPro cess" 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 FileSystemObjec t 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.


            Comment

            Working...