直接判断貌似没这可能,看看c的If IO.File.Exists(SKYTemplateFile) = False Then ‘文件不存在 If SKYTemplatePath.IndexOf("\\") = 0 Then If Connect(SKYTemplatePath, lpRemoteUsr, lpRemotePass) = False Then ShowMsgBox("...") Return False ElseIf IO.File.Exists(SKYTemplateFile) = False then ShowMsgBox("...") Return False End If Else ShowMsgBox("...") Return False End If End If
Public Function Connect(ByVal lpRemoteName As String, ByVal lpRemoteUsr As String, ByVal lpRemotePass As String) As Boolean Dim intRtn As Integer
Try
Dim typNetResource As NETRESOURCE
With typNetResource .dwScope = RESOURCE_CONNECTED .dwType = RESOURCETYPE_DISK .dwDisplayType = RESOURCEDISPLAYTYPE_SHARE .dwUsage = RESOURCEUSAGE_CONTAINER ''.lpLocalName = LocalName .lpRemoteName = lpRemoteName End With
intRtn = WNetAddConnection2(typNetResource, lpRemotePass, lpRemoteUsr, CONNECT_UPDATE_PROFILE) Select Case intRtn Case 0 '连接 Case Else '连接Error Return False
End Select
Return True
Catch ex As Exception Throw ex Return False Finally End Try
‘文件不存在
If SKYTemplatePath.IndexOf("\\") = 0 Then
If Connect(SKYTemplatePath, lpRemoteUsr, lpRemotePass) = False Then
ShowMsgBox("...")
Return False
ElseIf IO.File.Exists(SKYTemplateFile) = False then
ShowMsgBox("...")
Return False
End If
Else
ShowMsgBox("...")
Return False
End If
End If
Public Function Connect(ByVal lpRemoteName As String, ByVal lpRemoteUsr As String, ByVal lpRemotePass As String) As Boolean
Dim intRtn As Integer
Try
Dim typNetResource As NETRESOURCE
With typNetResource
.dwScope = RESOURCE_CONNECTED
.dwType = RESOURCETYPE_DISK
.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
.dwUsage = RESOURCEUSAGE_CONTAINER
''.lpLocalName = LocalName
.lpRemoteName = lpRemoteName
End With
intRtn = WNetAddConnection2(typNetResource, lpRemotePass, lpRemoteUsr, CONNECT_UPDATE_PROFILE)
Select Case intRtn
Case 0
'连接
Case Else
'连接Error
Return False
End Select
Return True
Catch ex As Exception
Throw ex
Return False
Finally
End Try
End Function
楼主可以试试
(!Directory.Exists("\\对方ip\要找的文件夹"));
但是要找的文件夹必须是共享的你能访问到,
我去 好吧 我表示我看错问题了。话说能实现吗 你如果能随意看到对方的文件不就是黑了他的电脑了吗。。
我表示,一开始也看错了。
有两种概念:
第一是,对方电脑必须要有可利用的漏洞。
第二是,对方电脑必须提供一种接口。
有以上两种的其中一种,就可以实现你的功能了。
但第一种有点扯淡。
我详细说说第二种,利用第二种提供接口,让对方电脑给你返回信息。可以是文件夹共享、FTP、WEB SERVICE、套接字、windows消息队列等