b_o_b
asked on
Copy Files to computers on a Network using a Windows Service
Aim:
Be able to copy files to different computers(on a network) using a Windows Service
Project:
Using a Windows Service, it calls a frmService.vb (VB.NET Windows Form) that contains a function which performs actions such as downloading files from FTP to my computer and deploying files to different computers on a network (to a shared folder).
Problem:
Downloading a file from FTP is OK, but, copying (deploying) the files to computers on a network raises an error saying: ...
========================== ========== ========== ========== ========
System.IO.IOException: The network path was not found
at System.IO._Error.WinIOErro r(Int32 errorCode, String str)
at System.IO.File.InternaleCo py(String sourceFileName, String destFileName, Boolean Overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean OverWrite)
at v2k_functions.filecopy(Str ing srcFile, String destFile)
========================== ========== ========== ========== =======
========================== ========== ========== ========== =======
System.UnauthorizedAccessE xception: Access to the path "\\NAME\A\B\abc.mde" is denied.
System.IO.IOException: The network path was not found
at System.IO._Error.WinIOErro r(Int32 errorCode, String str)
at System.IO.File.InternaleCo py(String sourceFileName, String destFileName, Boolean Overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean OverWrite)
at v2k_functions.filecopy(Str ing srcFile, String destFile)
========================== ========== ========== ========== ========
Here is the Function that performs the copying of a file to computers:
Function filecopy(ByVal srcfile As String, ByVal destfile As String)
Try
Dim x As IO.File
x.Copy(srcfile, destfile, True)
Return True
Catch e1 As Exception
MsgBox(e1.ToString)
Return False
End Try
End Function
For x = 0 to arrNames.Length - 1
Dim dest1 As String
dest1 = "\A\B\abc.mde"
If filecopy("C:\V2KSUS\Visual 2000 Report.mde", "\\" + arrNames(x) + dest1) = False Then
' If successful then put them in an array
Else
' Count how many computers that has been copied successfully
End If
Next
Possible Cause:
- Since I installed the Windows Service using a LOCAL SYTEM account, I might have no access to computers in the network.
************************** ********** ********** ********** ********** ******
>> If I install the service using a NETWORK SERVICE or LOCAL SERVICE account, it does not work.
Possible Cause:
- The frmService.vb has MessageBox and ProgressBar, it does not allow any MessageBox or any interface. Using the LOCAL SYSTEM allows to interact with the desktop.
>> On the other hand, I also tried executing the form without using a Windows Service and it works perfectly.
Be able to copy files to different computers(on a network) using a Windows Service
Project:
Using a Windows Service, it calls a frmService.vb (VB.NET Windows Form) that contains a function which performs actions such as downloading files from FTP to my computer and deploying files to different computers on a network (to a shared folder).
Problem:
Downloading a file from FTP is OK, but, copying (deploying) the files to computers on a network raises an error saying: ...
==========================
System.IO.IOException: The network path was not found
at System.IO._Error.WinIOErro
at System.IO.File.InternaleCo
at System.IO.File.Copy(String
at v2k_functions.filecopy(Str
==========================
==========================
System.UnauthorizedAccessE
System.IO.IOException: The network path was not found
at System.IO._Error.WinIOErro
at System.IO.File.InternaleCo
at System.IO.File.Copy(String
at v2k_functions.filecopy(Str
==========================
Here is the Function that performs the copying of a file to computers:
Function filecopy(ByVal srcfile As String, ByVal destfile As String)
Try
Dim x As IO.File
x.Copy(srcfile, destfile, True)
Return True
Catch e1 As Exception
MsgBox(e1.ToString)
Return False
End Try
End Function
For x = 0 to arrNames.Length - 1
Dim dest1 As String
dest1 = "\A\B\abc.mde"
If filecopy("C:\V2KSUS\Visual
' If successful then put them in an array
Else
' Count how many computers that has been copied successfully
End If
Next
Possible Cause:
- Since I installed the Windows Service using a LOCAL SYTEM account, I might have no access to computers in the network.
**************************
>> If I install the service using a NETWORK SERVICE or LOCAL SERVICE account, it does not work.
Possible Cause:
- The frmService.vb has MessageBox and ProgressBar, it does not allow any MessageBox or any interface. Using the LOCAL SYSTEM allows to interact with the desktop.
>> On the other hand, I also tried executing the form without using a Windows Service and it works perfectly.
This is not a .NET problem, make sure the service is running under a domain account that has access to all of the computers that need to be connected to. For example, since it works perfectly when you're running it, use your own credentials.
ASKER
Need some further explanation
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.