질문하기질문하기
 

답변됨[net2.0] FTP - GetFileSize

  • 2005년 9월 24일 토요일 오후 10:26reg3x 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Hi!
    I want to retrieve the Filesize of a file
    on  a ftp-server.
    I tried this listing :

            Dim size As String
            Dim reader As StreamReader = Nothing

            Try
                Dim request As FtpWebRequest = WebRequest.Create("ftp://server.com")
                request.Credentials = New NetworkCredential("anonymous", "anonymous")
                request.Method = WebRequestMethods.Ftp.GetFileSize
                Dim response As FtpWebResponse = request.GetResponse
                reader = New StreamReader(response.GetResponseStream)
                size = reader.ReadLine()
                MsgBox("Size : " + size)
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally

                If reader IsNot Nothing Then
                    reader.Close()
                End If

            End Try

    ... You see. It connects to a ftp-server and (I think) retrieves the Filesize.
    But the read line, which is put into the Variable "size" is empty.
    (I tested the Code with real ftp-usernames and logons on my server.)

    You can help me, to retrieve the FileSize of an File on a ftp-Server?

    , reg3x
    (I'm German Big Smile)

답변

  • 2005년 9월 25일 일요일 오전 3:00Durgaprasad Gorti중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    response.ContentLength should give you the size
  • 2005년 9월 25일 일요일 오후 3:39Durgaprasad Gorti중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
          Dim size As Integer
            Dim reader As StreamReader = Nothing

            Try
                Dim request As FtpWebRequest = WebRequest.Create("ftp://server.com")
                request.Credentials = New NetworkCredential("anonymous", "anonymous")
                request.Method = WebRequestMethods.Ftp.GetFileSize
                Dim response As FtpWebResponse = request.GetResponse
                size = response.ContentLength
                MsgBox("Size : " + size)
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally

                If reader IsNot Nothing Then
                    reader.Close()
                End If

            End Try

모든 응답

  • 2005년 9월 25일 일요일 오전 3:00Durgaprasad Gorti중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    response.ContentLength should give you the size
  • 2005년 9월 25일 일요일 오후 3:33reg3x 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Yes I read this in a thread, before.
    U can write the Whole syntax?
  • 2005년 9월 25일 일요일 오후 3:39Durgaprasad Gorti중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
          Dim size As Integer
            Dim reader As StreamReader = Nothing

            Try
                Dim request As FtpWebRequest = WebRequest.Create("ftp://server.com")
                request.Credentials = New NetworkCredential("anonymous", "anonymous")
                request.Method = WebRequestMethods.Ftp.GetFileSize
                Dim response As FtpWebResponse = request.GetResponse
                size = response.ContentLength
                MsgBox("Size : " + size)
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally

                If reader IsNot Nothing Then
                    reader.Close()
                End If

            End Try
  • 2005년 9월 25일 일요일 오후 4:34reg3x 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Oh!
    Nearly the same, I did :D
    Workz!
    Than you very much!

    greets reg3x
  • 2007년 3월 16일 금요일 오전 12:23tuzojazz 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Thanks!!

    it works

    but the correct sintax is

     

    MsgBox("Size : " & size)