Guidance
指路人
g.yi.org
software / rapidq / Examples / File & Directory / QSHFileOperation / QSHFileOperation_sample.bas

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=========================================================
'=========================================================
'========     Sample code for file operations     ========
'=========================================================
'=========================================================

     $INCLUDE "QSHFileOperation.inc"

     CONST TRUE = 1
     CONST FALSE = 0
     CONST NULL = FALSE

     DECLARE SUB FOp
     DECLARE SUB FOpEnd

     DIM Form AS QFORM
     Form.CAPTION = "SHFileOperation sample"
     Form.Width = Form.Width / 1.4
     Form.Height = Form.Height * 1.35

     DIM RichEdit AS QRICHEDIT
     RichEdit.PARENT = Form
     RichEdit.Align = 5
     RichEdit.AddStrings("Press any key...")
     RichEdit.OnChange = FOp

     DIM FileOp AS QSHFileOperation
     FileOp.DefaultFlagsEx = fofSimpleProgress OR fofNoConfirmMkDir OR fofRenameOnCollision
    'It is possible to set flag as default one and later when calling object, see below
    'Use .DefaultFlagsEx = 0 or DefaultFlags = 0 to reset those properties
     Form.SHOWMODAL

     SUB FOp
      counter++

      SELECT CASE counter

      CASE 1
       RichEdit.Clear

       SHfoResult = FileOp.CopyEx("c:\autoexec.bat","c:\temp_dir1\autoexec.bat",fofSimpleProgress,NULL)
       IF SHfoResult = 0 THEN
        RichEdit.AddStrings("Copying 1 made", "     Press any key...")
       ELSE
        RichEdit.AddStrings("Copying 1 failed", "     Press any key...")
       END IF

      CASE 2
       SHfoResult = FileOp.Copy("c:\config.sys","c:\temp_dir1\config.sys")
       IF SHfoResult = 0 THEN
        RichEdit.AddStrings("Copying 2 made", "     Press any key...")
       ELSE
        RichEdit.AddStrings("Copying 2 failed", "     Press any key...")
       END IF

      CASE 3
       FileOp.DefaultFlagsEx = 0 'Resets .DefaultFlagsEx
       FileOp.DefaultFlagsEx = fofSimpleProgress
       SHfoResult = FileOp.CopyEx("c:\temp_dir1\*.*","c:\temp_dir2",NULL,NULL)
       IF SHfoResult = 0 THEN
        RichEdit.AddStrings("Copying 3 made", "     Press any key...")
       ELSE
        RichEdit.AddStrings("Copying 3 failed", "     Press any key...")
       END IF

      CASE 4
       SHfoResult = FileOp.RENAME("c:\temp_dir1","c:\temp_dir3")
       IF SHfoResult = 0 THEN
        RichEdit.AddStrings("Renaming made", "     Press any key...")
       ELSE
        RichEdit.AddStrings("Renaming failed", "     Press any key...")
       END IF

      CASE 5
       SHfoResult = FileOp.Delete("c:\temp_dir2",TRUE,FALSE)
       IF SHfoResult = 0 THEN
        RichEdit.AddStrings("Deleting 1 (to Bin) made", "     Press any key...")
       ELSE
        RichEdit.AddStrings("Deleting 1 (to Bin) failed", "     Press any key...")
       END IF

      CASE 6
       SHfoResult = FileOp.Delete("c:\temp_dir3",FALSE,TRUE)
       IF SHfoResult = 0 THEN
        RichEdit.AddStrings("Deleting 2 made", "     Press any key...")
       ELSE
        RichEdit.AddStrings("Deleting 2 failed", "     Press any key...")
       END IF

       RichEdit.AddStrings("", "-----", "Finnish - remove files from Bin...","     Press any key to exit...")
       RichEdit.OnChange = FOpEnd

      END SELECT
     END SUB

     SUB FOpEnd
      END
     END SUB

'= End ===================================================
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2019-4-19  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-01-11 21:15:48