http://www.autoitx.com/forum.php ... p;extra=&page=2
$a="c:\windows\notepad.exe"
msgbox(0,'test',_getfileinfo(_getfileinfo($a,3),0))
Func _GetFileInfo($spath, $Sflag = 0)
$spath = StringRegExpReplace($spath, '["' & "']", '')
Select
Case $Sflag = 3 ;获取文件目录
If StringRegExp($spath, '\\') Then
$sFileInfo = StringRegExpReplace($spath, '\\[^\\]*$', '')
Else
$sFileInfo = ''
EndIf
Return ($sFileInfo)
Case $Sflag = 2;给出文件扩展名
$sFileInfo = StringRegExpReplace($spath, '.+\.', '')
Return ($sFileInfo)
Case $Sflag = 1 ;给出文件名但不包含扩展名
$sFileInfo = StringRegExpReplace($spath, '.+\\', '')
$sFileInfo = StringRegExpReplace($sFileInfo, '\.[^\.]*$', '')
Return $sFileInfo
Case $Sflag = 0 ;给出文件名包含扩展名
$sFileInfo = StringRegExpReplace($spath, '.+\\', '')
Return $sFileInfo
Case Else
Return False
EndSelect
EndFunc ;==>_GetFileInfo
|