Re: mkdir



It could be 'inheritable directory permissions' Ken

To the OP: right-click on the new directory and look at the properties in
the Security tab. What does it say?

Tony Proctor

"Ken Halter" <Ken_Halter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eMn664iOFHA.1096@xxxxxxxxxxxxxxxxxxxxxxx
> "droose" <droose@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:864F5C38-3069-46BE-9742-EC333008E6F9@xxxxxxxxxxxxxxxx
> > When I use the mkdir command the directory created is read only, making
it
> > worthless. Does anyone know why or how to work around this?
> > Thanks
> > ***
>
> Post your code. There's no reason that I know of that a read-only
attribute
> would be tacked on "magically". Does it actually have the read-only
> attribute set?
>
> fwiw, here's a basic template you can use to create nested folders in VB
or
> using the WinAPI (api's less code, by far <g>)
> '================
> Option Explicit
>
> Private Declare Function MakeSureDirectoryPathExists Lib _
> "IMAGEHLP.DLL" (ByVal DirPath As String) As Long
>
>
> Private Sub Command1_Click()
> If VBCreatePath("C:\Temp\Any\Thing\You\Want") = True Then
> Debug.Print "VB Success!"
> End If
> If APICreatePath("C:\Temp\Another\Way") = True Then
> Debug.Print "API Success!"
> End If
> End Sub
>
> Private Function APICreatePath(NewPath) As Boolean
>
> 'Add a trailing slash if none
> If Right(NewPath, 1) <> "\" Then
> NewPath = NewPath & "\"
> End If
>
> 'Call API
> If MakeSureDirectoryPathExists(NewPath) <> 0 Then
> 'No errors, return True
> APICreatePath = True
> End If
>
> End Function
>
> Private Function VBCreatePath(NewPath As String) As Boolean
> Dim vArr As Variant
> Dim sPath As String
> Dim sCurrent As String
> Dim iFor As Integer
>
> On Error GoTo ErrorTrap
>
> 'Remove any trailing backslash
> sPath = NewPath
> If Right$(sPath, 1) = "\" Then
> sPath = Left$(sPath, Len(sPath) - 1)
> End If
>
> 'Split the path into an array
> vArr = Split(sPath, "\")
>
> 'Create the folder(s)
> For iFor = 0 To UBound(vArr)
> sCurrent = sCurrent & vArr(iFor) & "\"
> ' Debug.Print sCurrent, Dir(sCurrent, vbDirectory)
> If Len(Dir(sCurrent, vbDirectory)) = 0 Then
> MkDir sCurrent
> End If
> Next iFor
>
> 'If it got this far with no errors, all's well.
> VBCreatePath = True
>
> Terminate:
> Exit Function
>
> ErrorTrap:
> Debug.Print Err.Number, Err.Description
> Debug.Assert False
> Resume Terminate
> End Function
> '================
>
> --
> Ken Halter - MS-MVP-VB - http://www.vbsight.com
> Sign up now to help keep VB support alive - http://classicvb.org/petition
> Please keep all discussions in the groups..
>
>


.


Loading