Solved

ftp to unix

Posted on 2006-11-13
4
780 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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