1. David Pylatuk
  2. PowerBuilder
  3. Wednesday, 8 May 2024 20:58 PM UTC

Hello everyone,

I am on PB2022/3289 and building for PowerServer. How do I create a folder using the CreateDirectory function?

Is it possible to create a multifolder path like:

C:\user1\temp\logfiles 

 

With just one call or do I have to create folders one at a time?

 

Thank you,

Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Friday, 10 May 2024 01:50 AM UTC
  2. PowerBuilder
  3. # 1

Hi David,

Please notice that PowerServer is using the same runtime as native PowerBuilder except for some database-related operations (e.g.: retrieve/update...). The CreateDirectory function is the same as the native PowerBuilder.

If you want to create a multi-folder path like C:\user1\temp\logfiles, you need to make sure "C:\user1" and "C:\user1\temp\" exist. Otherwise, you need to create these folders first. You can test the CreateDirectory function in the native PowerBuilder app.

Alternatively, you can extend a function of_createdirectorytree if not such a function in your current framework. E.g.:

Long ll_pos
Long ll_start = 1
String ls_tmp

If Right(as_directorytree, 1) <> "\" Then as_directorytree = as_directorytree + "\"

ll_pos = Pos( as_directorytree, "\", ll_start)
Do While ll_pos > 0
	ls_tmp = Trim(Left( as_directorytree, ll_pos - 1))
	If Len(ls_tmp) = 0 Then Return -1
	
	If DirectoryExists( ls_tmp ) = False Then
		If Createdirectory( ls_tmp ) = -1 Then Return -1
	End If
	
	ll_start = ll_pos + 1
	ll_pos = Pos( as_directorytree, "\", ll_start)
Loop

Regards, Logan

 

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 8 May 2024 21:06 PM UTC
  2. PowerBuilder
  3. # 2

Hi, David -

I suggest you try it. It should take you no more than a minute to temporarily add a command button to a window to test it.

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.