Please Help! - Count Files On Ftp Server

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts Page 1 of 1
Contributors
User avatar
MoDy kareem
New Member
New Member
Posts: 21
Joined: Fri Jan 15, 2010 3:43 pm

Hi,
I'm looking for a way to count files on an ftp server cryer;
Please Help me cryer; cryer; cryer; cryer; cryer;
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Hello MoDy Kareem,
Why do you have two threads about this?
Top-notch casual Dating
User avatar
MoDy kareem
New Member
New Member
Posts: 21
Joined: Fri Jan 15, 2010 3:43 pm

Sorry Wrong dunnno;
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Try:
Code: Select all
        Dim req As FtpWebRequest = FtpWebRequest.Create("ftp://localhost/directory")
        req.Credentials = New NetworkCredential("user", "password")
        req.Method = WebRequestMethods.Ftp.ListDirectory

        Dim resp As FtpWebResponse = req.GetResponse()
        Dim sr As StreamReader = New StreamReader(resp.GetResponseStream())

        Dim filelist As String = sr.ReadToEnd()
        sr.Close()
        resp.Close()

        Dim filecount As Integer = 0
        For i As Integer = 0 To filelist.Length - 1
            If filelist(i) = vbLf Then filecount += 1
        Next
        MsgBox(filecount)
User avatar
MoDy kareem
New Member
New Member
Posts: 21
Joined: Fri Jan 15, 2010 3:43 pm

mandai wrote:
Try:
Code: Select all
        Dim req As FtpWebRequest = FtpWebRequest.Create("ftp://localhost/directory")
        req.Credentials = New NetworkCredential("user", "password")
        req.Method = WebRequestMethods.Ftp.ListDirectory

        Dim resp As FtpWebResponse = req.GetResponse()
        Dim sr As StreamReader = New StreamReader(resp.GetResponseStream())

        Dim filelist As String = sr.ReadToEnd()
        sr.Close()
        resp.Close()

        Dim filecount As Integer = 0
        For i As Integer = 0 To filelist.Length - 1
            If filelist(i) = vbLf Then filecount += 1
        Next
        MsgBox(filecount)
Thanks thats work cooll; cooll; cooll;
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

If you got what you wanted, then please lock the topic so this doesn't gets bumped whenever a member posts a post.
Image
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Usman55 wrote:
If you got what you wanted, then please lock the topic so this doesn't gets bumped whenever a member posts a post.
like yesterday , there was a post on a topic that wasn't used for like 10/11 months
http://vagex.com/?ref=25000
7 posts Page 1 of 1
Return to “Coding Help & Support”