Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 788
  • Last Modified:

ftp to unix

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
bozworthy
Asked:
bozworthy
  • 2
  • 2
1 Solution
 
Bob LearnedCommented:
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
 
bozworthyAuthor Commented:
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
 
Bob LearnedCommented:
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
 
bozworthyAuthor Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now