Asked by:
FtpWebRequest to remote SD card direction

Question
-
Hi,
I have FTP server and I can connect to it with FileZilla Client , or just Command Prompt. That device has SD card and I can reach it too.
With command prompt I can reach sd card location:
ftp>open 192.168.1.50 user pass cd s:/
and it works. I see my .csv files.
In FileZilla settings i just add:
Default remote directory: s:\
But with Visual C# I can't access that.
string ftpPath = "ftp://192.168.1.50/%2Fs:/meters.csv"; FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpPath); request.Method = WebRequestMethods.Ftp.DownloadFile; request.Credentials = new NetworkCredential(user, pass); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream);
If I put file in device interternal memory, code works:
ftp://192.168.1.50/meters.csv"
I tried a lot of URI options but none of them worked...
For example:
ftp://192.168.1.50/%2F/s:/meters.csv"
ftp://192.168.1.50/%2Fs:/meters.csv"
and similar...
Have any suggestions?
- Edited by laurynasJ Sunday, November 12, 2017 6:02 PM mistake
- Moved by Wendy ZangMicrosoft contingent staff Tuesday, November 14, 2017 10:11 AM
Sunday, November 12, 2017 6:02 PM
All replies
-
Hello laurynasJ,
When you enter the location url that only contains ip address and port number,it will enter the default file path that you have set the "physical path" in configuration.The below is ftp setting in IIS manager tools.
If you want get correct url I suggest you use browser to access the ftp URL and get entire url path of documents. It would be correct path.
And I have noticed you set default remote directory as "s:\", the url don't need to contain it again. As for "cd:s" in the command prompt, it's a default file path of server side.Sincerely,
Neil HuMSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, November 13, 2017 10:14 AM -
Hello neil hu!
Thank you for your answer. The thing is that I can reach device internal memory ftp just typing ip address in Windows Explorer. But if I need to reach SD card location I can't access it with Windows Explorer. So manufacturer suggested to use FileZilla, and type default remote folder as "s:\". I don't really know what it's, but it works. And it works with command prompt with typing cd s:/. But the problem is how can I reach it with visual C#.
Maybe that location of s:/ is virtual or something... I don't know.Here is command prompt, and as you see there is no s:/ location but I can reach it:
230 User logged in, proceed.
ftp> dir
200 Command okay.
150 File status okay; about to open data connection.
drw-rw-rw- 1 owner group 0 Sep 10 11:50 PLC
drw-rw-rw- 1 owner group 0 Sep 10 11:50 webserv
drw-rw-rw- 1 owner group 0 Sep 10 11:50 etc
drw-rw-rw- 1 owner group 0 Sep 10 11:50 certstore
-rw-rw-rw- 1 owner group 8826 Nov 12 18:31 METERS.CSV
226 Closing data connection. Requested file action successful.
ftp: 337 bytes received in 0,00Seconds 337000,00Kbytes/sec.
ftp> cd s:/
250 Requested file action okay, completed.
ftp> dir
200 Command okay.
150 File status okay; about to open data connection.
-rw-rw-rw- 1 owner group 8828 Nov 13 13:53 meters.csv
drw-rw-rw- 1 owner group 0 Aug 3 16:49 ARCHIVE
226 Closing data connection. Requested file action successful.
ftp: 139 bytes received in 0,00Seconds 139,00Kbytes/sec.Monday, November 13, 2017 12:07 PM -
Hello laurynasJ,
I'm sorry that we are not support for third party tools . If you have question with "FileZilla" , you should post a new thread to FileZilla Forum for suitable support.
If you have some grammar or code errors in using c#, please feel free to contact us. We will try our best to give you a solution .
Sincerely,
Neil Hu
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Tuesday, November 14, 2017 10:10 AM -
Hello,
I think I know what's the problem. I tried other ftp library and it worked. For my solution it is need to firstly login to ftp server and just after that change folder to "s:/".
For example i used limilabs library:
client.Connect(textServer.Text); client.Login(textUserName.Text, textPassword.Text); client.ChangeFolder("s:/"); client.Download("meters.csv", @"" + folder + @"\meters.csv");
And it works!
But with standard library:
string ftpPath = "ftp://192.168.1.50/%2Fs:/meters.csv"; FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpPath);
It doesn't work because it connects straight to file.
How can I do connection to server and change folder direction after that in FtpWebRequest?
Thank you!
Tuesday, November 14, 2017 12:15 PM