Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Listing Directory using FTPwebrequest and updating DB tables

Listing Directory using FTPwebrequest and updating DB tables

Scheduled Pinned Locked Moved Visual Basic
databasecom
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sachin k Rajput
    wrote on last edited by
    #1

    I'm listing the directories using FTPWebRequest and updating the data into a sql table. My code is:

    If Con.State = ConnectionState.Closed Then Con.Open()
    ObjEventlog.WriteEventLog("TimerListing_Task()", "Connection Is Open Now")
    Dim Rs As SqlDataReader = com.ExecuteReader(CommandBehavior.CloseConnection)
    While Rs.Read
    ''ExecuteQuerys("Delete from temp_Listing_result where deviceID=" & Rs(0))
    ListBox1.Items.Add("Listing DeviceID-->" & Rs(0).ToString & " Start...")
    ObjEventlog.WriteEventLog("TimerListing_Task()", "Table temp_Listing_result Is Refresh Now For Device ID---> " & Rs(0).ToString)
    Dim arr() As String
    Dim request As FtpWebRequest = WebRequest.Create("ftp://" & Rs(1) & ":" & Rs(2) & "/" & Rs(3))
    request.Credentials = New NetworkCredential(Rs(4).ToString, Rs(5).ToString)
    request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
    Dim response As FtpWebResponse = request.GetResponse()
    Dim responseStream As Stream = response.GetResponseStream()
    Dim reader As StreamReader = New StreamReader(responseStream)
    ObjEventlog.WriteEventLog("TimerListing_Task()", "WebRequest is Created with ----> " & "ftp://" & Rs(1) & ":" & Rs(2) & "/" & Rs(3))
    Dim loadData As String = ""
    Dim lineNumber As Integer = 0
    While loadData IsNot Nothing
    loadData = reader.ReadLine()

                    arr = Split(loadData, vbNewLine)
                    For i = 0 To UBound(arr)
                        If Len(arr(i)) > 0 Then
                            Dim ss As String = arr(i)
                            ObjEventlog.WriteEventLog("TimerListing\_Task()", "WebRequest Listing Result---> " & ss)
                            Dim isFolder As String = ss.Substring(0, 4)
                            If isFolder <> "drwx" Then
                                ss = Trim(ss.Substring(28))
                                ObjEventlog.WriteEventLog("TimerListing\_Task()", "WebRequest Listing Result After Split---> " & ss)
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups