Alok-Agarwal
asked on
Equivalent of .Net Code in VBScript
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)
Try
Dim ByPassUrls() As String
Dim loNetworkCredentials As NetworkCredential
loNetworkCredentials = New NetworkCredential(Util.Get Setting("N etworkCred entialUser id"), _
Util.GetSetting("NetworkCr edentialPa ssword"), _
Util.GetSetting("NetworkCr edentialDo main"))
Dim proxy As New WebProxy(Util.GetSetting(" WebProxyNa me"), _
Util.GetSetting("WebProxyP ortNumber" ), ByPassUrls, loNetworkCredentials)
Dim req As HttpWebRequest
req = WebRequest.Create(uploadUr l)
req.Method = "POST"
req.Proxy = proxy
req.Credentials = loNetworkCredentials
req.AllowWriteStreamBuffer ing = 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 <> ""
wrtr.WriteLine(inLine)
inLine = rdr.ReadLine()
End While
rdr.Close()
wrtr.Close()
Dim objResponse As WebResponse
objResponse = req.GetResponse()
Dim result As String
Dim sr As StreamReader
sr = New StreamReader(objResponse.G etResponse Stream())
result = sr.ReadToEnd()
sr.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
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)
Try
Dim ByPassUrls() As String
Dim loNetworkCredentials As NetworkCredential
loNetworkCredentials = New NetworkCredential(Util.Get
Util.GetSetting("NetworkCr
Util.GetSetting("NetworkCr
Dim proxy As New WebProxy(Util.GetSetting("
Util.GetSetting("WebProxyP
Dim req As HttpWebRequest
req = WebRequest.Create(uploadUr
req.Method = "POST"
req.Proxy = proxy
req.Credentials = loNetworkCredentials
req.AllowWriteStreamBuffer
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 <> ""
wrtr.WriteLine(inLine)
inLine = rdr.ReadLine()
End While
rdr.Close()
wrtr.Close()
Dim objResponse As WebResponse
objResponse = req.GetResponse()
Dim result As String
Dim sr As StreamReader
sr = New StreamReader(objResponse.G
result = sr.ReadToEnd()
sr.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
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.
Thanks
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.
Thanks
Hello:
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
http://msdn.microsoft.com/en-us/library/ms535874%28v=vs.85%29.aspx
Best regards.
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
http://msdn.microsoft.com/en-us/library/ms535874%28v=vs.85%29.aspx
Best regards.
ASKER