Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi

below is the code i am using

C#
Directory.CreateDirectory(gsOutputUNCPath);


where gsOutputUNCPath=\\10.149.5.29\d$\FixOmaticTemps

error i am getting is Access to the path '\\10.149.5.29\d$\FixOmaticTemps' is denied.

This is my own system path.

Please need help to resolve
Posted
Comments
Andy Lanng 9-Jun-15 10:16am    
It might be your own system, but you are accessing it via the network.

Are you sure that the application user is local user (you)?
Have you shared the d drive folder with appropriate access?
Black_Rose 9-Jun-15 10:19am    
Yes. i did.
Andy Lanng 9-Jun-15 10:20am    
hmm - can you access it by typing that path into windows explorer (without being prompted for a u/name&p/word)?
Richard Deeming 9-Jun-15 10:50am    
Which version of Windows are you running? Recent versions of Windows don't let you change the permissions on the administrative shares.

This article[^] might be relevant.

1 solution

I know this is a long work around but map the path virtually if you don't have access to it.
My code is in VB, sorry
If you need the full code just ask

VB
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" _
(ByRef lpNetResource As NETRESOURCE, ByVal lpPassword As String, _
ByVal lpUserName As String, ByVal dwFlags As Integer) As Integer


    Public Structure NETRESOURCE
        Public dwScope As Integer
        Public dwType As Integer
        Public dwDisplayType As Integer
        Public dwUsage As Integer
        Public lpLocalName As String
        Public lpRemoteName As String
        Public lpComment As String
        Public lpProvider As String
    End Structure

    Public Const ForceDisconnect As Integer = 1
    Public Const RESOURCETYPE_DISK As Long = &H1

Dim nr As NETRESOURCE
nr = New NETRESOURCE
        nr.lpRemoteName = UNCPath
        nr.lpLocalName = DriveLetter & ":"
        strUsername = sUserName
        strPassword = sPassword
        nr.dwType = RESOURCETYPE_DISK

        Dim result As Integer
        result = WNetAddConnection2(nr, strPassword, strUsername, 0)
        sError = result

        Select Case result
            Case "53"
                MsgBox("Invalid Network Path" & Environment.NewLine & " The '\' At The End Of The Path Is Not Required", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical)
            Case "86"
                MsgBox("Invalid Username Or Password Setup", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical)
        End Select
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900