Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

FTP Send File

Posted on 2014-03-21
3
Medium Priority
?
364 Views
Last Modified: 2014-03-24
I am working my way through a piece of code debugging it

   


        Dim FTPServer As String = "ftp://ukftp.alyanto.com"
        Dim UserName As String = "alyanto"
        Dim Password As String = "expertsexchange"
        Dim FilePath As String = "C:\Users\tongcheeka\Documents\Adware\ScannerImport\FTPExport\Bad00021032014141633.csv"

       

        Try
            Dim oURI As New System.Uri(FTPServer)

            Dim fwr As FtpWebRequest = DirectCast(FtpWebRequest.Create(oURI), FtpWebRequest)
            fwr.Method = WebRequestMethods.Ftp.UploadFile
            fwr.Credentials = New NetworkCredential(.UserName, Password)
            fwr.Proxy = Nothing
            fwr.UsePassive = False
            Dim reader As New FileStream(oFTP.SourceFile, FileMode.Create, FileAccess.ReadWrite)
            Dim buffer(Convert.ToInt32(reader.Length - 1)) As Byte
            reader.Read(buffer, 0, buffer.Length)
            reader.Close()
            fwr.ContentLength = buffer.Length
            Dim stream As Stream = fwr.GetRequestStream
            stream.Write(buffer, 0, buffer.Length)
            stream.Close()

        Catch ex As Exception
            Debug.Print(ex.Message)
            Throw ex
        End Try

Open in new window


At Dim stream As Stream = fwr.GetRequestStream it throws this error

 'The requested URI is invalid for this FTP command.  

The team I am with believe the URL we are using is correct.  I can use it to navigate to using the URL via windows.  I suspect it is some combination of the URL and file name I need but I keep finding myself at a dead end.

Can someone make suggestion on how I might resolve the issue?
0
Comment
Question by:Alyanto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 39945337
Include the target filename in your URL before you create the FtpWebRequest.

e.g.

Dim FTPServer As String = "ftp://ukftp.alyanto.com/somefile.data"

Open in new window

0
 
LVL 1

Author Comment

by:Alyanto
ID: 39945665
Craq on mate, Cheers /Aly
0
 
LVL 1

Author Closing Comment

by:Alyanto
ID: 39950942
Thank you again
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question