$fso.GetTempName ()
这里提示:错误:变量类型必须为对象类型("object")
脑子不够使了,没法理解,谁给说说.
顺便帮忙改一下好吗,谢谢
_Main()
Func _Main()
Local $s_temp = _CreateTempFileName()
Local $h_temp = FileOpen($s_temp, 1)
FileWrite($h_temp, "Hellow World!!!")
FileClose($h_temp)
$h_temp = FileOpen($s_temp, 0)
MsgBox(0, "Temp File Used", FileRead($h_temp))
FileClose($h_temp)
FileDelete($s_temp)
EndFunc ;==>_Main
Func _CreateTempFileName($i_CreateWhere = 2, $s_Path = '')
Local $fso = ObjCreate ("Scripting.FileSystemObject")
Local $tfolder, $tname
Local Enum $WindowsFolder, $SystemFolder, $TemporaryFolder, $CustomFolder
Switch $i_CreateWhere
Case $WindowsFolder
If FileExists(@WindowsDir & "\temp") Then
$tfolder = @WindowsDir & "\temp"
Else
$tfolder = @WindowsDir
EndIf
Case $SystemFolder ; not widely used, don't recommend using this location
$tfolder = @SystemDir
Case $TemporaryFolder
$tfolder = @TempDir
Case $CustomFolder
If @NumParams < 2 Then Return SetError(1, 1, "")
$s_Path = StringReplace($s_Path, "/", "\")
If StringRight($s_Path, 1) = "\" Then $s_Path = StringTrimRight($s_Path, 1)
$tfolder = $s_Path
Case Else
Return SetError(1, 1, "")
EndSwitch
$tname = $tfolder & "\" & $fso.GetTempName ()
Local $h_file = FileOpen($tname, 1)
If $h_file = -1 Then Return SetError(1, 1, "")
FileClose($h_file)
Return $tname
EndFunc ;==>_CreateTempFileName
[ 本帖最后由 木纳 于 2008-6-3 05:18 编辑 ] |