Answered by:
Windows store app - Uploading file to FTP server

Question
-
Okay there are MANY samples and tutorials on how to download files from FTP servers. But none on how to UPLOAD files to FTP servers in windows stores app. Which is what i really need. Does anyone know how to do this? Or direct me to a tutorial?
I know its possible , because there are several FTP apps in the windows store.
Sunday, August 4, 2013 7:46 AM
Answers
-
Hi Kalel111,
I'm not quite familiar with FTP stuff, but I'm trying to provide you some information.
I do think that most of the samples are using Windows.Networking.BackgroundTransfer to implement the FTP download action. This feature is ideal for large file downloads and upload operations using the HTTP and HTTPS protocols. FTP is supported, but only when conducting download operations.<//span>
Here is a sample using WebRequest to communicate with the FTP server, I don't know if method "STOR" can be used to upload somthing.
Best regards,
James He
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Proposed as answer by Dave SmitsMVP Monday, August 5, 2013 8:32 AM
- Marked as answer by kalel111 Monday, August 5, 2013 8:55 AM
Monday, August 5, 2013 4:26 AMModerator
All replies
-
Hi Kalel111,
I'm not quite familiar with FTP stuff, but I'm trying to provide you some information.
I do think that most of the samples are using Windows.Networking.BackgroundTransfer to implement the FTP download action. This feature is ideal for large file downloads and upload operations using the HTTP and HTTPS protocols. FTP is supported, but only when conducting download operations.<//span>
Here is a sample using WebRequest to communicate with the FTP server, I don't know if method "STOR" can be used to upload somthing.
Best regards,
James He
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- Proposed as answer by Dave SmitsMVP Monday, August 5, 2013 8:32 AM
- Marked as answer by kalel111 Monday, August 5, 2013 8:55 AM
Monday, August 5, 2013 4:26 AMModerator -
First, go Package.appxmanifest file and assign Capabilities to Internet(Client) and Internet(Client & Server)
To upload a file to FTP server RustemSoft Skater development Team developed the following function:
Public Async Function FTP_Uploader(ftpURL As String, filename As String, username As String, password As String, UploadText As String) As Task(Of Boolean)
Try
Dim request As WebRequest = WebRequest.Create(ftpURL + "/" + filename)
request.Credentials = New System.Net.NetworkCredential(username.Trim(), password.Trim())
request.Method = "STOR"
Dim buffer As Byte() = Encoding.UTF8.GetBytes(UploadText)
Dim requestStream As Stream = Await request.GetRequestStreamAsync()
Await requestStream.WriteAsync(buffer, 0, buffer.Length)
Await requestStream.FlushAsync()
Return True
Catch ex As Exception
Return False
End Try
End FunctionSaturday, September 7, 2013 6:15 PM -
Jamles,
I tried using WebRequest, but no success.
Keep trying other possibilities.
Tuesday, September 24, 2013 1:47 PM -
here is a sample that uses STOR and stream sockets for uploading a file... (http://code.msdn.microsoft.com/Windows-8-SocketsFtp-4fc23b33)
and the write up: http://canbilgin.wordpress.com/2014/03/30/ftp-endeavor-ii-upload-and-download-files/
Can Bilgin
Blog Samples CompuSightWednesday, April 9, 2014 4:16 PM