2016-11-11 2 views
0

내 컴퓨터에서 다른 원격 컴퓨터로 특정 파일을 복사하는 프로그램을 만들었습니다. 성공적으로이 작업을 수행했지만 드라이버 C : \에서만 수행합니다. 내 질문에 어떻게 파일을 D : \ 드라이브에 복사 할 수 있습니까?원격 컴퓨터에 파일 복사

나는 \ 157.60.113.28 \ D : \ testnew \ right.bmp을 추가하려고했지만 행운은 없습니다. 알려줘!

Imports System 
Imports System.Runtime.InteropServices 
Imports System.Security.Principal 
Imports System.Security.Permissions 
Public Class Form1 
<DllImport("advapi32.DLL", SetLastError:=True)> _ 
Public Shared Function LogonUser(ByVal lpszUsername As String, ByVal lpszDomain As String, _ 
    ByVal lpszPassword As String, ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _ 
    ByRef phToken As IntPtr) As Integer 
End Function 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
    Dim admin_token As IntPtr 
    Dim wid_current As WindowsIdentity = WindowsIdentity.GetCurrent() 
    Dim wid_admin As WindowsIdentity = Nothing 
    Dim wic As WindowsImpersonationContext = Nothing 
    Try 
     MessageBox.Show("Copying file...") 
     If LogonUser("Local Admin name", "Local computer name", "pwd", 9, 0, admin_token) <> 0 Then 
      wid_admin = New WindowsIdentity(admin_token) 
      wic = wid_admin.Impersonate() 
      System.IO.File.Copy("C:\right.bmp", "\\157.60.113.28\testnew\right.bmp", True) 
      MessageBox.Show("Copy succeeded") 
     Else 
      MessageBox.Show("Copy Failed") 
     End If 
    Catch se As System.Exception 
     Dim ret As Integer = Marshal.GetLastWin32Error() 
     MessageBox.Show(ret.ToString(), "Error code: " + ret.ToString()) 
     MessageBox.Show(se.Message) 
    Finally 
     If wic IsNot Nothing Then 
      wic.Undo() 
     End If 
    End Try 
End Sub 
End Class 

답변

0

당신이 찾고있는 경로는 다음과 같습니다

당신이 정기적으로 귀하의 컴퓨터에서 네트워크 드라이브로 네트워크 경로를 매핑하는 것이 현명 할 것입니다 원격 컴퓨터와 상호 작용해야하는 경우
\\157.60.113.28\D$\testnew\right.bmp 

.

mapping network drive

+0

Haleluia! 고맙습니다. –

+0

@RobertKodra 문제가 해결 된 경우 V를 답의 왼쪽에 표시하여 감사를 표하십시오. – Stavm

+1

물론 대답하겠다. 대답을 수락하기 위해 3 분을 기다려야한다고 말한다. 도움과 팁을 가져 주셔서 감사합니다! –

관련 문제