SHFileOperation在VB 2005中如何可以把本地文件拷贝到网络服务器指定文件夹内

asd939393 2012-02-26 02:52:37
不知怎的,VB6.0可以使用以把本地文件拷贝到网络服务器指定文件夹内.但转换成VB2005后就有问题.第一次运HFileOperation提示出错,再重复执行一次就可以了.
请教各位大虾到底什么问题.

VB6.0中的代码如下:

Public SHFILEOPSTRUCT1 As SHFILEOPSTRUCT 'SHFILEOPSTRUCT峔憿懱宆偺曄悢傪愰尵偡傞

Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Type
'僐僺乕
Public Const FO_COPY = &H2

'嶍彍
Public Const FO_DELETE = &H3

'堏摦
Public Const FO_MOVE = &H1

'柤慜偺曄峏
Public Const FO_RENAME = &H4

Private Function File_Do(sFile As String, oFile As String, F_Mode As Long)
' F_Mode:Copy FO_COPY /MOVE FO_MOVE /DELETE FO_DELETE /RENAME FO_RENAME
Dim lngSHFileReturn As Long

File_Do = 999 'Error Return:default

With SHFILEOPSTRUCT1
.hwnd = Me.hwnd '僼僅乕儉偺僂傿儞僪僂丒僴儞僪儖傪愝掕偡傞
.wFunc = F_Mode '僼傽僀儖偺憖嶌傪巜掕偡傞
.pFrom = sFile '僼傽僀儖傗僼僅儖僟偺俠俷俹倄尦傪愝掕偡傞
.pTo = oFile '僼傽僀儖傗僼僅儖僟偺俠俷俹倄愭傪愝掕偡傞
End With

On Error Resume Next
lngSHFileReturn = SHFileOperation(SHFILEOPSTRUCT1)
' Copy幚峴偺栠傝抣傪敾抐
If lngSHFileReturn <> 0 Then
File_Do = lngSHFileReturn 'Error return
Exit Function
End If

File_Do = 0 'success return
End Function
...全文
96 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
VB
创建于2007-09-28

1.6w+

社区成员

VB技术相关讨论,主要为经典vb,即VB6.0
申请成为版主
帖子事件
创建了帖子
2012-02-26 02:52
社区公告
暂无公告