So I wanted to upload a file or files from a Windows Application that I was developing, so a quick lookup on MSDN provided the following (link): –
My.Computer.Network.UploadFile ( "C:My DocumentsOrder.txt", _ http://www.cohowinery.com/upload.aspx)
On the face of it it couldn’t be easier. If you take a look at the How To article, you can see that it doesn’t explain how to code the web side of the app or what’s required.
After much Googling, I finally come up with the answer, UploadFile is a wrapped for the WebClient.UploadFile Method. Reading this article provides more information.
The receiving ASPX page or upload.aspx as in the above example, requires the following code.
<%@ Import Namespace="System"%> <%@ Import Namespace="System.IO"%> <%@ Import Namespace="System.Net"%> <%@ Import NameSpace="System.Web"%> <Script language="VB" runat=server> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim f As String Dim file For Each f In Request.Files.AllKeys file = Request.Files(f) file.SaveAs("c:inetpubtestUploadedFiles" & file.FileName) Next f End Sub </Script> <html> <body> <p> Upload complete. </p> </body> </html>