[Gambas-user] Try Catch fail when using mkdir....

Fabien Bodard gambas.fr at ...626...
Sat Jul 2 11:26:24 CEST 2011


sorry i've done it directly without gambas ... the correction :

private sub CreateDirTree(sDir as string)

 dim s as string
 if sdir begins "/" then sdir = right(sdir,-1)

 For each s in split(sDir, "/")
   sDir &/= s
   if exist(stmpdir) then continue
   mkdir stmpdir
 next

catch
Print "The directory " & stmpdir & "can't be created"

end




2011/7/1 Stephen Bungay <sbungay at ...981...>:
>   Greetings Fabien!
>
>   That works very well, and is so much smaller and cleaner than the SUB
> you put in the initial email. By the way, that first SUB would have had
> a problem creating the stmpDir folder, it would, as written, not put in
> the delimiting "/" characters and would try to create a directory
> "/homeuser_name" and fail. This was a result of using the "for each" and
> "Split", necessites the addition of a counter or a boolean variable so
> the logic knows when it is on the first pass through the loop and
> handles all other passes by using "stmpDir &= "/" & s"  instead of
> "stmpDir &= s".
>
> On 07/01/2011 06:13 AM, Fabien Bodard wrote:
>> This is the good way in your way ... but it's a bad way in my fill
>>
>> Private Sub CreateNewOutputFolder(sFolderSpec As String)
>>
>>    If Not Exist(sFolderSpec) Then Mkdir sFolderSpec
>>
>>   Catch
>>      'if problem try on the prec folder
>>      CreateNewOutputFolder(File.Dir(sFolderSpec))
>>      'Re Try the folder creation if all is good
>>      Mkdir sFolderSpec
>>
>> End
>>
>>
>> Because you can't manage correctly all the errors.
>>
>> ------------------------------------------------------------------------------
>> All of the data generated in your IT infrastructure is seriously valuable.
>> Why? It contains a definitive record of application performance, security
>> threats, fraudulent activity, and more. Splunk takes this data and makes
>> sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-d2d-c2
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard




More information about the User mailing list