FTP

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using the following code to FTP a file:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim clsRequest <span style="color:Blue; As System.Net.FtpWebRequest = _
<span style="color:Blue; DirectCast(System.Net.WebRequest.Create(<span style="color:#A31515; "ftp://ftp.myserver.com/test.txt"), _
[/code]
<div style="color:Black;background-color:White; <pre>
System.Net.FtpWebRequest)
clsRequest.Credentials = <span style="color:Blue; New System.Net.NetworkCredential(<span style="color:#A31515; "myusername", <span style="color:#A31515; "mypassword")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

<span style="color:Green; read in file...
<span style="color:Blue; Dim bFile() <span style="color:Blue; As <span style="color:Blue; Byte = System.IO.File.ReadAllBytes(<span style="color:#A31515; "C:XMLst_fig.xml")

<span style="color:Green; upload file...
<span style="color:Blue; Dim clsStream <span style="color:Blue; As System.IO.Stream = _
clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
[/code]

<div style="color:Black;background-color:White; <pre>
This <span style="color:Blue; all works great APART <span style="color:Blue; from the fact that <span style="color:Blue; my file name <span style="color:Blue; is being lost <span style="color:Blue; in the transfer.
[/code]
The file appears in the designated folder but it is just called XML. How do I keep the filename?
Thanks
Roy <hr class="sig Roy T

View the full article
 
Back
Top