hallo,
ik ben bezig met een script dat bestanden naar een nieuwe directory copieerd. de gebruiker selecteerd het bestand en het script upload het naar een standaard locatie. jammer genoeg krijg ik het niet voor elkaar om het script mijn source directory uit mijn textbox te laten lezen. handmatig een directory invullen werkt wel.
mijn script:
als ik SHCopyFile txtFrom.Text, txtTo.Text aanpas naar SHCopyFile "c:\test.txt", "e:\test.txt" werkt het wel. wat doe ik fout?
ik ben bezig met een script dat bestanden naar een nieuwe directory copieerd. de gebruiker selecteerd het bestand en het script upload het naar een standaard locatie. jammer genoeg krijg ik het niet voor elkaar om het script mijn source directory uit mijn textbox te laten lezen. handmatig een directory invullen werkt wel.
mijn script:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40
Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
Dim sh_op As SHFILEOPSTRUCT
With sh_op
.hWnd = 0
.wFunc = FO_COPY
.pFrom = from_file & vbNullChar & vbNullChar
.pTo = to_file & vbNullChar & vbNullChar
.fFlags = FOF_ALLOWUNDO
End With
SHFileOperation sh_op
End Sub
Private Sub cmdcopy_Click()
SHCopyFile txtFrom.Text, txtTo.Text
End Sub
Private Sub Form_Load()
Dim file_path As String
file_path = "c:\"
If Right$(file_path, 1) <> "\" Then file_path = file_path & "\"
txtFrom.Text = file_path & "TestFrom.txt"
txtTo.Text = file_path & "TestTo.txt"
End Sub |
als ik SHCopyFile txtFrom.Text, txtTo.Text aanpas naar SHCopyFile "c:\test.txt", "e:\test.txt" werkt het wel. wat doe ik fout?
[ Voor 14% gewijzigd door Verwijderd op 11-01-2006 10:37 . Reden: opmaak ]