|
-
Sep 9th, 2000, 09:05 PM
#1
Thread Starter
Addicted Member
1) How can I MAKE A DIR ??
2) How can my program check if the dir exist ,
If not, create the path
EX:
want to put someting here:
c:\program files\project1\DATA\INI\LIST\
and only this dirrectory exist:
c:\program files\
So, I must do that :
if exist c:\program files\project1\DATA\INI\LIST\ then
'place my code here
else
create c:\program files\project1\DATA\INI\LIST\
end if
-
Sep 9th, 2000, 09:15 PM
#2
Here you go:
Code:
If Dir("C:\program files\", vbDirectory) <> "" Then
MkDir "C:\program files\project1\DATA\INI\LIST\"
Else
Msgbox "Cannot create directory!", vbCritical
End If
Or to check if the c:\program files\project1\DATA\INI\LIST\ exists or else create it:
Code:
If Dir("C:\program files\project1\DATA\INI\LIST\", vbDirectory) <> "" Then
MkDir "C:\program files\project1\DATA\INI\LIST\"
Else
Msgbox "Cannot create directory!", vbCritical
End If
-
Sep 9th, 2000, 09:21 PM
#3
Thread Starter
Addicted Member
thank's a lot ..
I'll try it ..
-
Sep 10th, 2000, 12:14 AM
#4
Thread Starter
Addicted Member
If NOT Dir("C:\program files\project1\DATA\INI\LIST\", vbDirectory) <> "" Then
MkDir "C:\program files\project1\DATA\INI\LIST\"
Else
Msgbox "Cannot create directory!", vbCritical
End If
You forgot the If not ..
-
Sep 10th, 2000, 01:33 AM
#5
Nope, it's not needed. The <> is inequality. So, it's like this:
Code:
x = Dir("C:\dir\")
'if it exists, it will return C:\dir
'if not...it will return nothing ( )
If x <> "" Then 'If x is not equal to nothing ( )
MkDir x 'make the directory
Else 'if it doesn't exist
Msgbox "Cannot create directory!", vbCritical
End If
If you were to use the code you gave, it'd be:
Code:
If NOT Dir("C:\program files\project1\DATA\INI\LIST\", vbDirectory) = "" Then
MkDir "C:\program files\project1\DATA\INI\LIST\"
Else
Msgbox "Cannot create directory!", vbCritical
End If
-
Sep 10th, 2000, 01:37 AM
#6
Thread Starter
Addicted Member
I try the 2 code.....
the first doesn't work so I out a NOT..
now It's working..
look:
Code:
Private Sub TXT_save_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Not Dir(TXT_save, vbDirectory) <> "" Then
If MsgBox("Le directoire :" & vbCrLf & TXT_save & vbCrLf & "n' existe pas ..." & vbCrLf & "Souhaitez-vous le créé ?", vbYesNo, "IRISA") = vbYes Then
MkDir TXT_save
Else
Exit Sub
End If
End If
If Not Right$(TXT_save, 1) = "\" Then
TXT_save = TXT_save & "\"
End If
On Error GoTo erreur
'|||SAVING FILE PATH|||
End If
Exit Sub
erreur:
MsgBox "Impossible d' écrire !", vbCritical, "IRISA"
End Sub
-
Sep 10th, 2000, 01:56 AM
#7
Oops, sorry for arguing with you. Didn't even realize it was your thread. Well, as long as it works, that's all that matters.
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
|