Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload FtpWebRequest issue

Status
Not open for further replies.

benjatado

Programmer
May 15, 2005
52
0
0
US
Hi -

I am attempting to upload files to ftp via the .NET FtpWebRequest.

I can upload the file to the ftp via a stream method, but cannot figure out how to specify the "target file name" on the ftp.

Code:
 Dim Ftp As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(Host), System.Net.FtpWebRequest)

Ftp.Credentials = New System.Net.NetworkCredential(User, Password)

Ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFileWithUniqueName

Dim bFile() As Byte = System.IO.File.ReadAllBytes(FilePath)

Dim clsStream As System.IO.Stream = Ftp.GetRequestStream()

clsStream.Write(bFile, 0, bFile.Length)
Ftp.RenameTo.ToString(UPC)
clsStream.Close()

clsStream.Dispose()

This uploads the file, but with a binary filename like "0879tmp"

Any help on this would be much appreciated!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top