cancel
Showing results for 
Search instead for 
Did you mean: 

Directory Check

former_member203861
Participant
0 Kudos

Hi all ,

How do I  check if directory is exists for the current  user running ( with permissions ) ?

I do some saving to a network path with in the app  and need to check first .

Thanks ,

Moshe

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

The DirectoryExists function will tell you if it exists. To check permissions, use FileOpen to create a dummy file. If it returns -1, you do not have permission. If the FileOpen worked, call FileClose and FileDelete.

Answers (2)

Answers (2)

Former Member
0 Kudos

Check the directory exists 'AAA':

If FileExists( 'C:\Temp\AAA\.' ) Then

  Messagebox('MSG', 'Directory exists')

Else

  Messagebox('MSG', 'Directory NOT exists' )

End If

Former Member
0 Kudos

Hi Moshe;

   You could use ....

1) SDK call:  Create or remove a directory - Real's PowerBuilder How-to

Note: in Real's examples, change each SDK command name from an "A" to a "W" to ensure Unicode compliance.

2) Run DOS command:  RUN ("CMD /C md C:\abc")

3) Use the PFC file service: of_createdirectory in n_cst_filesrv.

4) To check for a Directory, the the command DirectoryExists

For verifying the folder's existence and the users rights, make sure you check the Directory creation return codes and use a FileOpen command and check its return code for privileges

FWIW: I would also wrap all your I/O scripts in a TRY..CATCH.

HTH

Regards ...