MKDIR issue
Posted
#1
(In Topic #206)
Administrator

I can create the first level directory, but when trying to create a directory inside I get an "access forbidden" error.
Testing code:
Code
Public Sub Form_Open()
If Not Exist(User.Home &/ "Test") Then Mkdir (User.Home &/ "Test")
If Not Exist("Test/Test1") Then Mkdir ("Test/Test1")
End
This is the actual block of code used in many of my apps that worked without issue:
Code
Public Sub CheckDirIntegrity()
If Not Exist(User.Home &/ Mglobal.sBaseDir) Then Mkdir (User.Home &/ Mglobal.sBaseDir) ' check for base directory
If Not Exist(Mglobal.sAppDirPath) Then Mkdir (Mglobal.sAppDirPath) ' check for application directory
If Not Exist(Mglobal.sConfigPath) Then Mkdir (Mglobal.sConfigPath) ' check for configuration directory
If Not Exist(Mglobal.sDataPath) Then Mkdir (Mglobal.sDataPath) ' check for data directory
End
Posted
Guru

Line 1 refers to /home/<name>/Test
Line 2 refers to /Test/Test1 - You need root access to create this, hence the error.
Your first line is correct but your second line also needs the 'User.Home &/'. The code below works.
If it worked on older versions of Gambas the bug was there and not in the latest version.
I hope that helps.
Posted
Administrator

I figured out what was wrong:
1. working on code after coming home from 12 hours of work on too little sleep and being awake almost 16 hours :shock:
2. remembering differently what code I thought I copied and what I actually copied
3. updating Gambas in the middle of coding
4. trying to debug during [1.] above thinking [3.] above was the issue
5. posting "test" code that wasn't fully representative of my actual code
Your answer didn't make much sense to me since I knew my code had "User.Home" as part of the path string, so I started comparing old code to new code. After about 10 minutes of staring at code I realized that when copying old code to the new app, I didn't copy all the code.
1 guest and 0 members have just viewed this.


