Solved

ftp to unix

Posted on 2006-11-13
4
783 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
[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
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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