Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
See more:
My supplied code is that to copy/read the txt file from server m/c to client m/c through connecting lan Network. But arrise error message i.e.(The network path was not found.) how can i solve this problem. Please give me to supply currect response as early as possible.My code is given 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
            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", "\\\c\right.txt", True) ''
                MessageBox.Show("Copy succeeded")
                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())
            If wic IsNot Nothing Then
            End If
        End Try
    End Sub
End Class

I waiting for response because it is very important for me.
Updated 10-Sep-19 1:22am
koolprasadd 21-Sep-11 8:30am
Make sure "\\\c\" path is exist ?
start-->Run--> paste the path and hit enter. error suggest that there is error in path
Rate this:
Please Sign up or sign in to vote.

Solution 1

Unless you gave your share a specific name, this is what you should use:


You forgot the $ after the drive letter.
koolprasadd 21-Sep-11 8:39am
yes, it misses '$' after 'C', 5!
Rate this:
Please Sign up or sign in to vote.

Solution 3

Server Error in '/' Application.

The network path was not found
CHill60 10-Sep-19 9:11am
If you have a question of your own then use the red "Ask a Question" link at the top of this page. Do not post questions or comments as solutions to other members' problems

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100