PATH.GetFileInfo

Previous  Next

 

info = PATH.GetFileInfo( path      AS STRING, 

                         info-item AS INTEGER ) AS VARIANT

 


 

Returns information about the supplied file.  The result type depends on the information requested.  Dates returns as strings, the size as number of bytes as REAL, file attributes as INTEGER and the full name as STRING.

 

The following info-item constants have been defined in MyBASIC2_ExtLib.BIS.

 

GetFileInfo Information Items

 

CONST EL_FI_CreateDate           = 1   ' Returns STRING

CONST EL_FI_ModifiedDate         = 2   ' Returns STRING

CONST EL_FI_AccessDate           = 3   ' Returns STRING

CONST EL_FI_FileSize             = 4   ' Returns REAL

CONST EL_FI_Attributes           = 5   ' Returns INTEGER

CONST EL_FI_FullName             = 6   ' Returns STRING

 

File Attributes.  Can be OR'ed for multiple attributes

 

CONST EL_FA_normal               = 0x00000000

CONST EL_FA_readOnly             = 0x00000001

CONST EL_FA_hidden               = 0x00000002

CONST EL_FA_system               = 0x00000004

CONST EL_FA_volume               = 0x00000008

CONST EL_FA_directory            = 0x00000010

CONST EL_FA_archive              = 0x00000020

CONST EL_FA_temporary            = 0x00000100

CONST EL_FA_sparse               = 0x00000200

CONST EL_FA_reparsePoint         = 0x00000400

CONST EL_FA_compressed           = 0x00000800

CONST EL_FA_offline              = 0x00001000

CONST EL_FA_notIndexed           = 0x00002000

 

 

Example:

 

CONST cFileName = "e:\codetemplates\manual.txt"

CONST cTempName = "e:\codetemplates\manual_temp.txt"

 

IF FILEEXISTS( cFileName ) THEN

  IF PATH.GetFileInfo( cFileName, EL_FI_FileSize ) = 0 THEN

     PRINT "ERROR, Input File Size = 0.  Nothing to process.",

     STOP

  ENDIF

 

  PRINT "File Name:       ";PATH.GetFileInfo( cFileName, EL_FI_FullName ),

  PRINT "File Created:    ";PATH.GetFileInfo( cFileName, EL_FI_CreateDate ),

  PRINT "File Modified:   ";PATH.GetFileInfo( cFileName, EL_FI_ModifiedDate ),

  PRINT "File Accessed:   ";PATH.GetFileInfo( cFileName, EL_FI_AccessDate ),

  PRINT "File Size:       ";PATH.GetFileInfo( cFileName, EL_FI_FileSize )/1024;"KB",

  PRINT "File Attributes: ";HEX( PATH.GetFileInfo( cFileName, EL_FI_Attributes ) ),

 

  IF FILEEXISTS( cTempName ) THEN

     KILL cTempName

  ENDIF

 

  NAME cFileName AS cTempName

ENDIF