Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need to download excel file for server to my pc
or upload excel file to server from my pc

but the error say System.InvalidOperationException 'destinationFileName needs to include a file name

My.Computer.Network.DownloadFile("\\192.168.1.1\CableList.xlsx", "C:\Users\eng\Desktop\MECABLE", False, 500)


<pre>        My.Computer.Network.UploadFile("C:\Users\eng\Desktop\MECABLE", \\192.168.1.1\CableList.xlsx", False, 500)


What I have tried:

<pre>        My.Computer.Network.DownloadFile("\\192.168.1.1\CableList.xlsx", "C:\Users\eng\Desktop\MECABLE", False, 500)


<pre>        My.Computer.Network.UploadFile("C:\Users\eng\Desktop\MECABLE", \\192.168.1.1\CableList.xlsx", False, 500)



System.InvalidOperationException 'destinationFileName needs to include a file name
Posted
Updated 17-Jun-20 9:31am

1 solution

Sending data from a local machine to a remote machine is an upload.

Getting data from a remote machine to a local machine is a download.

The Download method always expects the first parameter to be the path to the file to download from the remote server. The second parameter is the filepath where you're going to save the file when downloaded.

In your case, you're trying to download from a server, but you're getting the UNC path wrong. UNC paths are always \\address\share\filepath. You're missing the share name.

Sorry, but nobody can tell you what that is. You set the server up, so you have to know what the share name of the folder you're sharing on it is.

You're also missing the name of the file to call the downloaded file when it's saved to your local machine.
VB.NET
My.Computer.Network.DownloadFile("\\192.168.1.1\missingShareName\CableList.xlsx", "C:\Users\eng\Desktop\MECABLE\missingFileName", False, 500)
 
Share this answer
 
Comments
katkot_rewsh 17-Jun-20 15:57pm    
Many thanks Dave
katkot_rewsh 17-Jun-20 15:57pm    
Many thanks Dave
Maciej Los 18-Jun-20 2:08am    
5ed!

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