Callisto82 / tftp.net

Implements the TFTP (Trivial File Transfer) protocol (client/server) in an easy-to-use C#/.NET library.
Microsoft Public License
80 stars 38 forks source link

Unable to send file (with filepath) #18

Closed matbcf closed 4 years ago

matbcf commented 4 years ago

Hi, I'm sorry for this easy and simple question but I'm a newbie in coding. I'm trying to upload a firmware file choose from user on a tftp server with your library, but if I call the upload function with the complete path of the file the IFTPTransferError give a 1 error (file not found). Received error: 1 - File not found Transfer failed1 - File not found If I try without filepath and copy my file in the debug folder the upload is finished without error . The simple question in this case is: there is a way to upload file directly from the folder that user choose? Thanks in advance for your reply.

Callisto82 commented 4 years ago

Hi! The path you are supplying to TftpClient.Upload() is the path that the file will be placed on the server. It's not the path to the file on your local computer. You probably want to do the following:

//the IP of your remote server var client = new TftpClient("192.168.0.2");

//the file will be saved as uploaded/firmware.bin on the server var transfer = client.Upload("uploaded/firmware.bin");

//the uploaded data will be taken from C;\Temp\ToUpload.bin on your pc transfer.Start(new FileStream("C:\Temp\ToUpload.bin"));