错误:拒绝指定路径 [英] Error : Access to specify path denied
本文介绍了错误:拒绝指定路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面提供了代码,并向我提供了代码.
我将代码更改为规定的代码.
但是出现另一个错误消息,即(拒绝访问路径``\\ 192.168.1.10 \ c $ \ right'')但我的txt文件已共享.
跟踪代码如下.
Below giving code posted and also provided code to me.
I change the code as like prescribed code.
But there is arise another error message i.e.(Access to path ''\\192.168.1.10\c$\right'' is denied) yet my txt file is shared.
The chaging code is below.
Imports System
Imports System.Runtime.InteropServices
Imports System.Security.Principal
Imports System.Security.Permissions
Public Class Form1
<dllimport("advapi32.dll",> _
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
If LogonUser("SNEHASIS\Administrator", "SNEHASIS", "", 9, 0, admin_token) <> 0 Then
wid_admin = New WindowsIdentity(admin_token)
wic = wid_admin.Impersonate()
System.IO.File.Copy("C:\file.txt", "\\192.168.1.10\c$\right.txt", True) ''157.60.113.28
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
我的上述问题有解决方案吗???
请提供正确的代码...
我等待回复.....
Have any solution for my above problem??????
Please supply right code ...
I wait for reply.....
推荐答案
\ right''被拒绝),但我的txt文件已共享.
跟踪代码如下.
\right'' is denied) yet my txt file is shared.
The chaging code is below.
Imports System
Imports System.Runtime.InteropServices
Imports System.Security.Principal
Imports System.Security.Permissions
Public Class Form1
<dllimport("advapi32.dll",> _
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
If LogonUser("SNEHASIS\Administrator", "SNEHASIS", "", 9, 0, admin_token) <> 0 Then
wid_admin = New WindowsIdentity(admin_token)
wic = wid_admin.Impersonate()
System.IO.File.Copy("C:\file.txt", "\\192.168.1.10\c
\ right.txt",真)' '157.60.113.28 MessageBox.Show(" ) 其他 MessageBox.Show(" ) 结束 如果 捕获 se As System.Exception Dim ret As 整数 = Marshal.GetLastWin32Error () MessageBox.Show(ret.ToString()," + ret.ToString()) MessageBox.Show(se.Message) 最后 如果 wic 是不是 没什么 然后 wic.Undo() 结束 如果 结束 尝试 结束 子 结束 类
\right.txt", True) ''157.60.113.28 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
我的上述问题有解决方案吗???
请提供正确的代码...
我等待答复.....
Have any solution for my above problem??????
Please supply right code ...
I wait for reply.....
要访问 C
To access the C
这篇关于错误:拒绝指定路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文