Results 1 to 3 of 3

Thread: Problem with code?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153
    hi there i want to create a directory on the C drive, this code isn't working do you have any ideas

    If sBackUp = "" Then
    ChDir "C:\"
    MkDir "tpbackup"
    sBackUp = "C:\tpbackup\bookbkup.mdb"
    End If

    Rohan West

  2. #2
    Member
    Join Date
    Jun 2000
    Location
    North of France
    Posts
    49

    Arrow

    Try this:

    Code:
       MkDir ("C:\tpbackup")
    Hi-Tech Engineer

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'Check if directory exists
    '-----------------------------------
    Public Function DirExists(ByVal sDirName As String) As Boolean
    
        Dim sDir As String
    
        On Error Resume Next
    
        DirExists = False
    
        sDir = Dir$(sDirName, vbDirectory)
        If (Len(sDir) > 0) And (Err = 0) Then
            DirExists = True
        End If
    
    End Function
    
    Private Sub command1_click()
    
        Dim sBackup As String, sDirectory As String
        
        sBackup = "C:\tpbackup\bookbkup.mdb"
        sDirectory = "C:\tpbackup"
        
        'does file exist using fso
        
        
        Dim fs As Object
        Set fs = CreateObject("Scripting.FileSystemObject")
        'if the file exists
        If fs.fileexists(sBackup) = True Then
        
        'check to see if directory exist to avoid error
        'if not create it
          If DirExists(sDirectory) = False Then
            MkDir "C:\aatpbackup"
          End If
        Else
            MsgBox "C:\sBackup Does Not Exist...Your code here!"
        End If
            Set fs = Nothing
    
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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