mkdir ...doesn't work

  • Thread starter Thread starter fth
  • Start date Start date
F

fth

Hello,
Is somebody could help me to resolve this case:
info Mainform.applipath (string)

NewMigPath = "d:\MigAppli\" & Mid([AppliPath], 4)

MkDir NewMigPath


I've a "error path not found" ...

Strange isn't it?

Many thanks by advance

Frederic
 
Hi,
when error occur, the complete path is correct ..
but I've message who said (path not found)

a idea?

Mtb advance
F

dlw said:
print out NewMigPath and see if it looks funny.

fth said:
Hello,
Is somebody could help me to resolve this case:
info Mainform.applipath (string)

NewMigPath = "d:\MigAppli\" & Mid([AppliPath], 4)

MkDir NewMigPath


I've a "error path not found" ...

Strange isn't it?

Many thanks by advance

Frederic
 
fth said:
Hello,
Is somebody could help me to resolve this case:
info Mainform.applipath (string)

NewMigPath = "d:\MigAppli\" & Mid([AppliPath], 4)

MkDir NewMigPath


I've a "error path not found" ...

Strange isn't it?

Many thanks by advance

Frederic

Do all the injtermewdiate folders in the path exist? If, for example,
"D:\MigAppli" doesn't exist, you have to create it first before you try
to create any subfolders in it.
 
MkDir can only create one level at a time. Thus, if you want to create a
(sub)Dir, says:

C:\TestDir\TestSubDir

and TestDir doesn't exist, you need to use MkDir *twice* like:

MkDir "C:\TestDir"
MkDir "C:\TestDir\TestSubDir"
 
Hello,
Yes, I understand that mkdir can't make a subfolder.
My problem is that the path is not the same for each record;

here's my code:

actualmigpath = Mid([AppliPath], 4)
NewMigPath = "d:\MigAppli"
FullPath = NewMigPath & actualmigpath

If Dir(FullPath) = "" Then
MkDir FullPath
....

My case is a solution to copy all my .mdb in a new directory where I create
sub folder like the original one.

Many thanks by advance

Fred


Van T. Dinh said:
MkDir can only create one level at a time. Thus, if you want to create a
(sub)Dir, says:

C:\TestDir\TestSubDir

and TestDir doesn't exist, you need to use MkDir *twice* like:

MkDir "C:\TestDir"
MkDir "C:\TestDir\TestSubDir"

--
HTH
Van T. Dinh
MVP (Access)


fth said:
Hello,
Is somebody could help me to resolve this case:
info Mainform.applipath (string)

NewMigPath = "d:\MigAppli\" & Mid([AppliPath], 4)

MkDir NewMigPath


I've a "error path not found" ...

Strange isn't it?

Many thanks by advance

Frederic
 
fth said:
Hello,
Yes, I understand that mkdir can't make a subfolder.
My problem is that the path is not the same for each record;

here's my code:

actualmigpath = Mid([AppliPath], 4)
NewMigPath = "d:\MigAppli"
FullPath = NewMigPath & actualmigpath

If Dir(FullPath) = "" Then
MkDir FullPath
...

My case is a solution to copy all my .mdb in a new directory where I
create sub folder like the original one.

Many thanks by advance

Here's a procedure that will build a folder path, creating any folders
that don't already exists:

'----- start of code -----
Sub MakePath(pstrPath As String)

Dim strPath As String
Dim aFolders() As String
Dim I As Integer

strPath = Trim(pstrPath)

If Len(strPath) = 0 Then
Err.Raise 5
Exit Sub
End If

aFolders = Split(strPath, "\")
strPath = vbNullString

For I = LBound(aFolders) To UBound(aFolders)
strPath = strPath & aFolders(I)
If Len(Dir(strPath, vbDirectory)) = 0 Then
MkDir strPath
End If
strPath = strPath & "\"
Next I

End Sub
'----- end of code -----

Warning: it's only lightly tested.

You should be able to use code like this:

actualmigpath = Mid([AppliPath], 4)
NewMigPath = "d:\MigAppli"
FullPath = NewMigPath & actualmigpath

If Len(Dir(FullPath, vbDirectory)) = 0 Then
MakePath FullPath
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top