|
-
Sep 13th, 2009, 09:21 AM
#1
Thread Starter
Addicted Member
[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 ) 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
-
Sep 13th, 2009, 09:27 AM
#2
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.
-
Sep 13th, 2009, 09:34 AM
#3
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
-
Sep 13th, 2009, 10:13 AM
#4
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
-
Sep 13th, 2009, 10:17 AM
#5
Thread Starter
Addicted Member
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.
-
Sep 13th, 2009, 10:20 AM
#6
Thread Starter
Addicted Member
Re: problem with mkdir command!
edgemeal, works a treat, thanks!
-
Sep 13th, 2009, 10:33 AM
#7
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:
path = data msgbox path 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
-
Sep 13th, 2009, 11:41 AM
#8
Thread Starter
Addicted Member
Re: [RESOLVED] problem with mkdir command!
the strange thing is, thats why i put that there, and the value of path is correct! :-|
strange
-
Sep 13th, 2009, 11:43 AM
#9
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.
-
Sep 13th, 2009, 11:48 AM
#10
Thread Starter
Addicted Member
Re: [RESOLVED] problem with mkdir command!
but it worked hard coded?
-
Sep 13th, 2009, 11:50 AM
#11
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|