VB如何实现复制一个文件到不存在的目录并改名?
比如说,c:\sss\sss.dll拷贝到e:\ddddddddd\ddddddd.exesss.dll和ddddddd.exe是同一个文件用VB是如何实现这样的操作的...
比如说,c:\sss\sss.dll 拷贝到 e:\ddddddddd\ddddddd.exe
sss.dll 和 ddddddd.exe 是同一个文件
用VB是如何实现这样的操作的 展开
sss.dll 和 ddddddd.exe 是同一个文件
用VB是如何实现这样的操作的 展开
2个回答
展开全部
写两个函数如下:
Function copyfiles(Surfile As String, filepath As String)
On Error GoTo Errhandle
Dim paths, pathtmp As String, x
pathtmp = Empty
paths = Split(filepath, "\")
For x = 0 To UBound(paths) - 1
DoEvents
If pathtmp = Empty Then
pathtmp = pathtmp & paths(x)
Else
pathtmp = pathtmp & "\" & paths(x)
End If
mdir pathtmp
Next
FileCopy Surfile, filepath
Exit Function
Errhandle:
MsgBox "文件" & Surfile & "复制到" & filepath & "错误"
Err.Clear
End Function
Function mdir(paths As String)
On Error Resume Next
MkDir paths
End Function
用的时候直接用
copyfiles 源文件, 目标文件
Function copyfiles(Surfile As String, filepath As String)
On Error GoTo Errhandle
Dim paths, pathtmp As String, x
pathtmp = Empty
paths = Split(filepath, "\")
For x = 0 To UBound(paths) - 1
DoEvents
If pathtmp = Empty Then
pathtmp = pathtmp & paths(x)
Else
pathtmp = pathtmp & "\" & paths(x)
End If
mdir pathtmp
Next
FileCopy Surfile, filepath
Exit Function
Errhandle:
MsgBox "文件" & Surfile & "复制到" & filepath & "错误"
Err.Clear
End Function
Function mdir(paths As String)
On Error Resume Next
MkDir paths
End Function
用的时候直接用
copyfiles 源文件, 目标文件
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询