subroutine ClearFilesInDir(cFileDir,iFile)
use DFLib, only: GetFileInfoQQ,GetLastErrorQQ,FILE$INFO,FILE$LAST,FILE$ERROR,FILE$FIRST,ERR$NOMEM, &
ERR$NOENT,FILE$DIR,DeldirQQ,DELFILESQQ,systemQQ
Implicit None
logical DirDeleted
Character(255) cFileName
Character*(*),Intent(IN)::cFileDir !,Dirtmp
!character*(*),intent(IN)::output
integer,Intent(Out)::iFile ! 找到文件的信息
Type(FILE$INFO)::info
Integer(4)::Wildhandle,length,iresult
Wildhandle=FILE$FIRST
iFile=0
dirdeleted=systemQQ('dir '//trim(cFileDir));pause
Do WHILE (.TRUE.)
iresult=GetFileInfoQQ(trim(cFileDir),info,Wildhandle) ! //'\' 不可以加在路径名后
print*,'creation=',info.creation
print*,'lastwrite=',info.lastwrite
print*,'lastaccess=',info.lastaccess
print*,'length=',info.length
print*,'permit=',info.permit
print*,'name=',trim(info.name)
print*,'handle=',Wildhandle
print*, 'iresult=', iresult
if( (Wildhandle.eq.FILE$LAST).or.(Wildhandle.eq.FILE$ERROR) )then
select case(GetLastErrorQQ())
case(ERR$NOMEM) ! 内存不足
iFile=-1
case(ERR$NOENT) ! 碰到通配符序列尾,正常退出
return
case default
iFile=0
Return
endselect
endif
iFile=iFile+1
cFileName=trim(info.Name)
print*,trim(info.Name)
print*,trim(cFileDir)
print*,' iFile=',iFile
DirDeleted=DELFILESQQ(trim(cFileDir)//'\'//trim(info.Name))
! call WriteFileName(Trim(info.Name),output,iFile) ! WriteFileName 函数没有定义
ENDDO
DirDeleted=DeldirQQ(cFileDir)
end subroutine ClearFilesInDir
fcode 发表于 2017-10-8 10:06
详解 http://cvfwin7.w.fcode.cn
为何不考虑 call system("rd /s /q cFileDir\*.*")
tmp.png (74.7 KB, 下载次数: 308)
fcode 发表于 2017-10-9 09:52
根据你的需求选择
rd /s /q E:\delft_grid\tmp
系统命令删除不成功界面与代码.png (36.11 KB, 下载次数: 316)
fcode 发表于 2017-10-9 17:05
c80_temp_2 = "rd /s /q " // trim(c80_temp_2)
注意加 /q ,不加 \*.*
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |