Solved

ftp to unix

Posted on 2006-11-13
4
774 Views
Last Modified: 2010-05-18
I have a unix server SunOs 5.8.  I can ping this server by using "ping ipaddress" or "ping hostname" or "ping hostname.company.com".  I can also ftp in and out of the this machine from dos or other unix servers .  

Due to a problem with Windows XP SP2 and Checkpoint VPN we can no longer use NFS (blue screen of death).
I'm trying to replace my NFS code with an FtpWebRequest to ftp files from Windows to Unix in my ASP.NET app.  I've tried every sample code on earth but can't get it to work.  

In the code below I'm getting an error regarding the URI.  Also the .METHOD statement does not accept any value that I give "GET, PUT, LISTDIRECTORY" etc.  What am I doing wrong?  (PS - I already wrote batch files to accomplish this and scrapped that idea because it didn't seem clean enough.  I also don't want to pay for a component to accomplish something that should be pretty standard and simple in ASP.NET...should be, but not for me).  

        Dim req As System.Net.FtpWebRequest
        Dim resp As System.Net.FtpWebResponse
        Dim data As System.IO.Stream
        Dim result As String        
        Dim creds As New System.Net.NetworkCredential("user", "user")
        req = DirectCast(System.Net.WebRequest.Create("ftp://hostname.company.com"), System.Net.FtpWebRequest)
        With req
            .Credentials = creds
            .UseBinary = True
            .KeepAlive = True
            .Method = "GET"
            resp = .GetResponse
            Data = resp.GetResponseStream
            result = resp.StatusCode
        End With
0
Comment
Question by:bozworthy
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17937654
Here is something a little different (untested):

        Dim result As String
        Dim creds As New NetworkCredential("user", "user")
        Dim req As FtpWebRequest = FtpWebRequest.Create("ftp://hostname.company.com")

        req.Credentials = creds
        req.UseBinary = True
        req.KeepAlive = True
        req.Method = WebRequestMethods.Ftp.DeleteFile
        Using resp As FtpWebResponse = req.GetResponse()
            Dim data As Stream = resp.GetResponseStream()
            result = resp.StatusCode
        End Using

Bob
0
 
LVL 1

Author Comment

by:bozworthy
ID: 17938459
Ok we're making good progress.  I'm able to sign in now.  However I do not see change directory(cd) as a valid WebRequestMethod.  I noticed in my Wrox VB.NET book that these methods are specific to the server.  I am able to cd through dos and other unix servers.  Why would cd not be available in this instance??

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 17938523
From what I remember, you can't send a change directory command through FtpWebRequest, you need to specify the target folder in the file path name that you are trying to FTP:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=564419&SiteID=1

Bob
0
 
LVL 1

Author Comment

by:bozworthy
ID: 17940762
The link to microsoft support is dead but I was able to get enough info from the post.  Thanks for your help.

 
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now