|
Win7, Compaq Visual Fortran 6.6.0。 想在主程序运行过程中删除一些废弃的文件和文件夹,需要编写一个删除文件夹的子程序,调用时指定文件夹路径,用到 GetFileInfoQQ 函数获取文件夹内文件信息,但调用时输出显示,获取的是文件夹名,而不是文件夹内的文件名,请指点:
[Fortran] 纯文本查看 复制代码 01 | subroutine ClearFilesInDir ( cFileDir , iFile ) |
02 | use DFLib , only : GetFileInfoQQ , GetLastErrorQQ , FILE $INFO , FILE $LAST , FILE $ERROR , FILE $FIRST , ERR $NOMEM , & |
03 | ERR $NOENT , FILE $DIR , DeldirQQ , DELFILESQQ , systemQQ |
06 | Character ( 255 ) cFileName |
07 | Character * ( * ) , Intent ( IN ) :: cFileDir |
09 | integer , Intent ( Out ) :: iFile |
11 | Integer ( 4 ) :: Wildhandle , length , iresult |
15 | dirdeleted = systemQQ ( 'dir ' / / trim ( cFileDir ) ) ; pause |
17 | iresult = GetFileInfoQQ ( trim ( cFileDir ) , info , Wildhandle ) |
18 | print * , 'creation=' , info.creation |
19 | print * , 'lastwrite=' , info.lastwrite |
20 | print * , 'lastaccess=' , info.lastaccess |
21 | print * , 'length=' , info.length |
22 | print * , 'permit=' , info.permit |
23 | print * , 'name=' , trim ( info.name ) |
24 | print * , 'handle=' , Wildhandle |
25 | print * , 'iresult=' , iresult |
26 | if ( ( Wildhandle .eq. FILE $LAST ) .or. ( Wildhandle .eq. FILE $ERROR ) ) then |
27 | select case ( GetLastErrorQQ ( ) ) |
38 | cFileName = trim ( info.Name ) |
39 | print * , trim ( info.Name ) |
41 | print * , ' iFile=' , iFile |
42 | DirDeleted = DELFILESQQ ( trim ( cFileDir ) / / '\' / / trim ( info.Name ) ) |
45 | DirDeleted = DeldirQQ ( cFileDir ) |
46 | end subroutine ClearFilesInDir |
|
|