i want to create a directory file in vb6 . please help !!!!

Dani AI

Generated

As asked how to make a folder and pointed toward the built-in statement, the short takeaway is: the single-statement approach is fine for one-level creation when the parent exists, but it fails (raises errors) if parents are missing or if permissions are denied. Below are two practical patterns that add safety and answer 's question about searching: a robust routine that creates nested folders using the Microsoft Scripting Runtime, and a simple Dir-based search loop.

Requires adding a reference to "Microsoft Scripting Runtime" (Project → References). This routine builds each level and tolerates existing folders:

' Requires reference to "Microsoft Scripting Runtime"
Dim fso As FileSystemObject
Set fso = New FileSystemObject
Dim folderPath As String
folderPath = "C:\myapp\data\newfolder"

If Not fso.FolderExists(folderPath) Then
    Dim parts As Variant
    parts = Split(folderPath, "\")
    Dim built As String
    If parts(0) <> "" Then
        built = parts(0) & "\"
    Else
        built = "\"
    End If
    Dim i As Long
    For i = 1 To UBound(parts)
        If parts(i) <> "" Then
            built = built & parts(i)
            If Not fso.FolderExists(built) Then
                On Error Resume Next
                fso.CreateFolder built
                On Error GoTo 0
            End If
            built = built & "\"
        End If
    Next i
End If

A compact file-search loop using the VB6 Dir function (answers ):

Dim fname As String
fname = Dir("C:\myapp\data\*.txt")
Do While fname <> ""
    Debug.Print fname
    fname = Dir()
Loop

Troubleshooting & tips: avoid illegal filename characters (<>:"/\|?* — colon only for drive), watch trailing backslashes and UNC paths (start with \\) which may need special handling, check permissions (use a writable folder like AppData if needed), and be mindful of legacy MAX_PATH limits on older systems. Prefer explicit existence checks and controlled error handling rather than swallowing errors silently.

The command to use is MKDir (the name of the DIR goes here- minus the parantheneses)

hi,what are the code you can use in search command?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.