Results 1 to 11 of 11

Thread: [RESOLVED] problem with mkdir command!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Resolved [RESOLVED] problem with mkdir command!

    Cant find out why this doesnt work!

    The following works...
    Code:
    'CREATE FOLDERS TO STORE THE DOWNLOADED FILES
    Private Sub createfolders()
        MkDir "c:\config\audio"
        MsgBox "folders done"
    End Sub
    But this wont!

    (The folders.dat file contains
    Code:
    c:\config\audio
    ) The msgbox displays the correct path, so it is reading it correctly. I get a 'Runtime Error 76: Path not found' error...

    Code:
    'CREATE FOLDERS TO STORE THE DOWNLOADED FILES
    Private Sub createfolders()
        Open "C:\config\folders.dat" For Input As #1
            Input #1, data
            path = data
            MkDir path
            MsgBox (path)
            Close #1
        MsgBox "folders done"
    End Sub
    Thyanks

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: problem with mkdir command!

    I'm not sure what 'data' contains. MKDir cannot create more than one subfolder at a time.

    If you had C:\1\2\3\4 as a path, in order to create \4, C:\1\2\3 would have to exist or be created first. So using MKDir, you want to split your path into separate subfolders and then ensure each subfolder exists and if not, then create that subfolder, one at a time.

    Also, MKDir will fail/error if the path already exists.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: problem with mkdir command!

    If your hardcoded code works then Try

    MkDir Trim(path)

    Probably some leading or trailing spaces are creating the problem...

    Also if you run the hardcoded code first then remember to delete the destination path before trying the softcoded code...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: problem with mkdir command!

    The SHCreateDirectoryEx API can make multiple sub folders in one call and won't error if the folder already exists, might want to try something like this,

    Code:
    Option Explicit
    'SHCreateDirectoryEx - Minimum operating systems: Windows 2000, Windows Millennium Edition
    Private Declare Function SHCreateDirectoryEx Lib "shell32" Alias "SHCreateDirectoryExA" (ByVal hwnd As Long, ByVal pszPath As String, ByVal psa As Any) As Long
    
    Private Sub createfolders()
        Dim sPath As String
        Open "C:\config\folders.dat" For Input As #1
        Do Until EOF(1)
            Line Input #1, sPath
            sPath = Trim$(sPath)
            If Len(sPath) > 0 Then SHCreateDirectoryEx Me.hwnd, sPath, ByVal 0&
        Loop
        Close #1
    End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: problem with mkdir command!

    Lavolpe,
    Thanks but it 'does' work when hardcoded, so that is not the issue (i dont think). Also yes, I have an error capture for existing directories, which I am ignoring for the tme being. Thanks

    Koolsid, still gives error with the 'trim'... Am goign to try edgemeals suggestion.

    thanks for your time.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: problem with mkdir command!

    edgemeal, works a treat, thanks!

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] problem with mkdir command!

    Great it is sorted...

    But out of curiosity, can you check what is the value of path at the time of error..

    vb Code:
    1. path = data
    2. msgbox path
    3. MkDir path
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: [RESOLVED] problem with mkdir command!

    the strange thing is, thats why i put that there, and the value of path is correct! :-|

    strange

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] problem with mkdir command!

    It isn't strange. I think that c:\config did not exist on the hard drive.
    Therefore MKDir c:\config\audio returns path not found because it can't create the audio subfolder without the config folder first being created.
    Substitute c:\config\audio with whatever was actually read into the Data/Path variable.

    Just a matter of understanding the MKDir requirements and limitations.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    145

    Re: [RESOLVED] problem with mkdir command!

    but it worked hard coded?

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] problem with mkdir command!

    It worked hardcoded because c:\config was already there.

    Proof: Try this, hardcoded:
    MKDir "C:\RootBogus_123\SubBogus_123"

    Path not found error will occur, because RootBogus_123 does not exist.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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