Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ftp to unix

Posted on 2006-11-13
4
Medium Priority
?
787 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

670 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