ftp to ws host

Posted on 2009-04-19
Medium Priority
Last Modified: 2013-12-09
Hi All,
I have written a program to create web pages and I want to ftp the finished page tp the web server when they are finished.  The code hangs up on this line
       Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
with the error message...

System.Net.WebException was unhandled
  Message="The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."
       at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
       at System.Net.FtpWebRequest.RequestCallback(Object obj)
       at System.Net.CommandStream.InvokeRequestCallback(Object obj)
       at System.Net.CommandStream.Abort(Exception e)
       at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
       at System.Net.FtpWebRequest.GetRequestStream()
       at WebBuilder.Form4.Button5_Click(Object sender, EventArgs e) in C:\WebBuilder\WebBuilder\WebBuilder\Form4.vb:line 78
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at WebBuilder.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

The web host is hosting two domains so I need to choose which one the file goes to, hense the line
        DirectCast(System.Net.WebRequest.Create("ftp://" & s1 & "/" & s1), System.Net.FtpWebRequest)
where the first s1 is the domain name and the second s1 is the directory for the domain.  They just happen to have the same bane.  It appears the program is making a connection with the server but for some reason not accepting the file upload.

Can anyone tell me whaat I am doing wrong?
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim s1, s2, s3, s4 As String
        ' set up request...
        s1 = Form1.TextBox3.Text
        s2 = Form1.TextBox1.Text & "\" & Form1.TextBox14.Text
        s3 = Form1.TextBox4.Text
        s4 = Form1.TextBox5.Text
        Dim clsRequest As System.Net.FtpWebRequest = _
        DirectCast(System.Net.WebRequest.Create("ftp://" & s1 & "/" & s1), System.Net.FtpWebRequest)
        clsRequest.Credentials = New System.Net.NetworkCredential(s3, s4)
        clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
        ' read in file...
        Dim bFile() As Byte = System.IO.File.ReadAllBytes(s2)
        ' upload file...
'Hangs up with error message on following line
        Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
        clsStream.Write(bFile, 0, bFile.Length)
    End Sub
End Class

Open in new window

Question by:dr_roose
LVL 57

Accepted Solution

giltjr earned 2000 total points
ID: 24184184
Do you have access to the ftp servers logs?  You may want to install something like wireshark (http://www.wireshark.org) and do a packet capture from your computer to verify what you are sending out.

The 550 error message means you are attempting to write to a directory that you either do not have permission to write to or does not exist, it can also mean you are attempting to over write and existing file that you do not have permission to write to.

One problem could be that the ftp server and web server have a different default starting location.


Author Closing Comment

ID: 31572057
Thank you very much.  I now have ftp capability

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Understanding FTPS File transfer is a common requirement in most Enterprises. While there are numerous ways to get a file from Point A to Point B over a network, perhaps the most common method still in use is FTP – File Transfer Protocol. FTP is …
SSL is a very common protocol used these days when browsing the web.  The purpose is to provide security to communication, but how does it do it?  There are several pieces at work that have to be setup before SSL will even work and it requires both …
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month14 days, 6 hours left to enroll

807 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