Equivalent of .Net Code in VBScript

Posted on 2011-05-09
Last Modified: 2013-11-26
Hi ,

I need to have VBScript equivalent code for below .Net code. Kindly let me know how to go about this.

  Public Sub UploadFile(ByVal localFile As String, ByVal uploadUrl As String)

            Dim ByPassUrls() As String
            Dim loNetworkCredentials As NetworkCredential

            loNetworkCredentials = New NetworkCredential(Util.GetSetting("NetworkCredentialUserid"), _
                                                     Util.GetSetting("NetworkCredentialPassword"), _

            Dim proxy As New WebProxy(Util.GetSetting("WebProxyName"), _
                                    Util.GetSetting("WebProxyPortNumber"), ByPassUrls, loNetworkCredentials)

            Dim req As HttpWebRequest
            req = WebRequest.Create(uploadUrl)

            req.Method = "POST"
            req.Proxy = proxy
            req.Credentials = loNetworkCredentials

            req.AllowWriteStreamBuffering = True

            req.ContentType = "application/x-wmflatfile"

            Dim reqStream As Stream

            reqStream = req.GetRequestStream()
            Dim wrtr As StreamWriter
            wrtr = New StreamWriter(reqStream)

            Dim rdr As StreamReader

            rdr = New StreamReader(localFile)

            Dim inLine As String

            inLine = rdr.ReadLine()

            While inLine <> ""
                inLine = rdr.ReadLine()
            End While


            Dim objResponse As WebResponse
            objResponse = req.GetResponse()

            Dim result As String
            Dim sr As StreamReader
            sr = New StreamReader(objResponse.GetResponseStream())
            result = sr.ReadToEnd()

        Catch ex As Exception
        End Try

    End Sub
Question by:Alok-Agarwal
    LVL 5

    Author Comment

    Basically I am trying to understand if there are equivalent objects in VBScript corresponding to objects that have been used in the above sub.
    LVL 8

    Accepted Solution

    It would be something like this.
    Best regards.
    sub get_html (up_http, down_http)
    dim xmlhttp
    set xmlhttp = createobject("msxml2.xmlhttp.3.0") "get", up_http, false

    Open in new window

    LVL 5

    Author Comment


    Thanks for the inputs. Is it possible to provide more details. Sorry , but I am not able to understand from the above few lines how the achieve the complete functionality that I provided in my original post.

    LVL 8

    Expert Comment

    I gave you the points to start doing you job.But I'm not going to do it for you ;-)
    Read the documentation about xmlhttp objects and its methods here

    Best regards.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now