Run-time error: '76' Path not found when creating a directory

Discussion in 'Software' started by ceal21c, Sep 25, 2006.

  1. ceal21c

    ceal21c Private E-2

    Hey Guys,

    When I use the following code to create a folder I get this error message, Run-time error: '76' Path not found.

    Dim fso As New FileSystemObject

    If fso.FolderExists("C:\A\B") = False Then
    fso.CreateFolder ("C:\A\B")
    End If

    BTW the folder "C:\A" already exists before I try to create the sub-directory. Thanx.
     
  2. matt.chugg

    matt.chugg MajorGeek

    Is it definatly this line that is throwing the exception ?

    fso.CreateFolder ("C:\A\B")

    the only way I can replicate the error is if the c:\a folder doesn't exist.

    if there is no 'a' folder in c: then it will fail but if it is there is it should be fine.

    I know you say the a folder is there but just try this code:

    Code:
        Dim fso As New FileSystemObject
        If Not (fso.FolderExists("c:\a")) Then
            fso.CreateFolder ("c:\a")
        End If
        
        If Not (fso.FolderExists("c:\a\b")) Then
            fso.CreateFolder ("c:\a\b")
        End If
    
     
    Last edited: Sep 25, 2006
  3. ceal21c

    ceal21c Private E-2

    Thanks for your reply matt. I understand your logic and I tried your suggestion but would you believe it, the program still crashes when it tries to create the subdirectory b when a is present on the root of c. I read somewhere that I may have to use a directory object instead of a file object. What do you think?
     
  4. ceal21c

    ceal21c Private E-2

    Thanks to everyone for your help it turns out that the directory "C:\A" where I was trying to create the new folder "B" would only allow me to create the folder if I changed the name! I was trying to create a backup folder with the actual name "PRN" for storing some .prn files. Only after I changed the directory name to "BKP" did the program stop crashing and create the folder. Does this make any sense to anyone?
     
  5. matt.chugg

    matt.chugg MajorGeek

    ahhh, if you'd have said PRN straigtaway I would have know the problem instantly.

    There are several dos device names that are reserved, as such you cannot make a folder or file with their name.

    Code:
    AUX              First connected serial port
    PRN              First connected parallel port
    COM1 thru COM4   Serial ports (modem, mouse, etc.)
    LPT1 thru LPT3   Parallel ports (printer)
    CON              Keyboard and screen
    NUL              Dummy (testing purposes)
    
     
  6. ceal21c

    ceal21c Private E-2

    Ahhhhhhhhhhhhhhh..........Gotcha! Now it makes sense. Thanx again.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds