Solved

FTP Send File

Posted on 2014-03-21
3
360 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

724 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