oi10:presentation_server:deletefiles_method_filesystem

DELETEFILES Method (System)

Deletes a set of specified files, optionally showing a progress information and allowing an Undo operation.

SuccessFlag = Exec_Method( "FILESYSTEM",    

                              "DELETEFILES",   

                              FilesList,       

                              DelFilesOptions )
NameRequiredDescription
FilesListYes@fm-delimited list of files to delete. Wildcard characters are allowed.
DelFilesOptionsNoContains an @Fm-delimited dynamic array of options that control the behavior of the delete operation:



<1> Allow undo

<2> Allow UI

<3> Parent window ID

<4> Progress dialog title

<5> Allow confirmations

TRUE$ if the delete was performed successfully, or FALSE$ if an error occurred. If the case of the latter event the FILEOPRESULT property may be used to obtain more details regarding the failure.

The DelFilesOptions argument is composed of five fields which control the behavior of the delete operation – each field is described fully below:

FieldNameDescription
<1>Allow undoIf TRUE$ then save Undo information. Defaults to FALSE$.
<2>Allow UIIf TRUE$ then allow any appropriate dialogs to be displayed such as progress and error information. Defaults to FALSE$.
<3>Parent window IDSpecifies the name of a WINDOW object to use as the parent for any dialogs displayed during the delete operation.
<4>Progress dialog titleText to display in the progress dialog during the delete operation.
<5>Allow confirmationsIf TRUE$ then allow the user to respond to any confirmation dialogs presented during the delete operation. Defaults to FALSE$.

The DELETEFILES method is basically a wrapper around the SHFileOperation Windows API function, so it is worth examining at the documentation for this on the MSDN website to get a better idea of the capabilities of this method.

You should use fully qualified path names with this method. Using it with relative path names is not thread safe.

Equated constants for use with the DELETEFILES method can be found in the PS_FILESYSTEM_EQUATES insert record.

 
// Use the FILESYSTEM DELETEFILES method to delete all files in a folder

   // using wildcard characters, showing any progress information, and

   // allowing the user to stop the operation.

   

   $Insert PS_FileSystem_Equates

   $Insert Logical

   

   FileList     = "c:\my_data\aug_2017\*.*"

   

   DelOptions = ""  

   DelOptions<PS_DLF_ALLOWUNDO$>     = TRUE$  ; // Save Undo info

   DelOptions<PS_DLF_ALLOWUI$>       = TRUE$  ; // Show dialogs

   DelOptions<PS_DLF_PARENTWINDOW$>  = @Window

   DelOptions<PS_DLF_PROGRESSTITLE$> = "Copying data to backup folder"

   DelOptions<PS_DLF_ALLOWCONFIRM$>  = TRUE$

   

   If Exec_Method( "FILESYSTEM", "DELETEFILES", FileList, DelOptions ) Then

      // Deleted OK

   End Else

      ErrorInfo = Get_Property( "FILESYSTEM", "FILEOPRESULT" )

      ErrorCode = ErrorInfo<PS_FOR_ERRORCODE$>

      ErrorText = ErrorInfo<PS_FOR_ERRORTEXT$>

   End

   // Use the FILESYSTEM DELETEFILES method to delete specific files in a folder

   // showing progress information, but not allowing the user to cancel the

   // operation.

   

   DirFrom       = "c:\my_data\aug_2017\"

   

   FileNames     = "book1.xls"

   FileNames<-1> = "book2.xls"

   

   FileList      = ""

   

   XCount = FieldCount( FileNames, @fm )

   For X = 1 To XCount

      FileList<x> = DirFrom : FileNames<x>

   Next  

   

   DelOptions = ""  

   DelOptions<PS_CPF_ALLOWUNDO$>     = TRUE$  ; // Save Undo info

   DelOptions<PS_CPF_ALLOWUI$>       = TRUE$  ; // Show dialogs

   DelOptions<PS_CPF_PARENTWINDOW$>  = @Window

   DelOptions<PS_CPF_PROGRESSTITLE$> = "Copying data to backup folder"

   DelOptions<PS_CPF_ALLOWCONFIRM$>  = FALSE$

   

   If Exec_Method( "FILESYSTEM", "DELETEFILES", FileList, DelOptions ) Then

      // Deleted OK

   End Else

      ErrorInfo = Get_Property( "FILESYSTEM", "FILEOPRESULT" )

      ErrorCode = ErrorInfo<PS_FOR_ERRORCODE$>

      ErrorText = ErrorInfo<PS_FOR_ERRORTEXT$>

   End
 
 
 

FILOPRESULT property.

  • oi10/presentation_server/deletefiles_method_filesystem.txt
  • Last modified: 2023/10/25 10:49
  • by 127.0.0.1