14. februar 2002 - 13:07
Der er
2 kommentarer og
1 løsning
Shell
Når man kører noget i en shell, f.eks. shell("dir", vbnormal), kan man så få den til at gemme sit output i en fil. Jeg har prøvet shell("dir >c:\res.txt"), som jo virker fra commando prompten!
14. februar 2002 - 16:13
#1
'----------------------------------------------- Form1 -----------------------------------------------
Option Explicit
Public Function LoadLocal(Path As String, Save As String)
On Error Resume Next
Dim NextLocal As String
Dim FullSpec As String
Dim idir As Long
Dim ifil As Long
ChDrive Path
ChDir Path
If Len(CurDir()) = 3 Then
FullSpec = CurDir() & "*.*"
Else
FullSpec = CurDir() & "\*.*"
End If
NextLocal = Dir(FullSpec, vbDirectory + vbNormal)
Open Save For Binary As #1
Do While NextLocal <> ""
If Len(CurDir()) = 3 Then
FullSpec = CurDir() & StrConv(NextLocal, vbProperCase)
Else
FullSpec = CurDir() & "\" & NextLocal
End If
If (GetAttr(FullSpec) And vbDirectory) = vbDirectory Then
Put #1, , CStr(StrConv(NextLocal, vbProperCase) & " - [DIR]" & vbNewLine) 'Dir
Else
Put #1, , CStr(StrConv(NextLocal, vbProperCase) & " - " & FileLen(FullSpec) & " byte" & vbNewLine) 'File
End If
NextLocal = Dir
Loop
Close #1
End Function
Private Sub Form_Load()
LoadLocal "C:\", "c:\res.txt"
End Sub
'----------------------------------------------- Form1 -----------------------------------------------