Results 1 to 3 of 3

Thread: creating files

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    creating files

    hey, ive got a form that runs a bat file, dont ask me why, i just wanted to play around, on an error trap if the bat file cant be found i want it to create a blank bat file. this has no reason, but i just really wanna no how to create stuff and really get to no VB. can some one plz help me a lil, ive looked and i think its got something to do with the Shell function but from there im lost.

    thanks

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    On Error GoTo TrapError1:

    Open "Test.bat" For Input As #1
    Close #1
    Shell "Test.bat"
    Exit Sub

    CreateFile:
    Open "Test.bat" For Output As #1
    Print #1. "ECHO Testing batch file"
    Close #1
    Shell "Test.bat"
    Exit Sub

    TrapError1:
    If Err = 52 Then Resume CreateFile

  3. #3
    Stiletto
    Guest
    To check if the file exist use this:
    VB Code:
    1. Dim sPath As String
    2. sPath = "C:\MyFolder\MyFile.bat"
    3. If Len(Dir(sPath)) <> 0 Then
    4.     MsgBox "File Exist"
    5. Else
    6.     MsgBox "No Such File!"
    7. End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width