473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Https: with VB

I'm looking for guidance to show developers information about implementing
https using VB so that an application which needs to transfer files securely
from within a VB client app can do so using https:

I'm aware the capability is available but need some guidance about where to
find the detailed information so I can help a developer learn something they
do not already know how to do.

Any help appreciated.

Feb 18 '06 #1
3 1665
Hi David,

Play with this....

Dim crdential As New System.Net.NetworkCredential("UserName", "Password")
UploadFile("c:\mylocalfolder\mylocalfile.txt",
"https://thewebsite.com/thedirectory/mylocalfile.txt", crdential)

----------------------------------
Friend Function UploadFile(ByVal SourceLocation As String, ByVal
DestinationLocation As String, ByVal Credential As
System.Net.NetworkCredential) As Boolean
Dim Response As String = Nothing, FileSize As Double = 0
Try
UploadFile = False
If SourceLocation.ToString.Trim <> "" And
DestinationLocation.ToString.Trim <> "" Then
'To set Upload settings
Dim UploadRequest As System.Net.HttpWebRequest =
CType(System.Net.WebRequest.Create(New
Uri(DestinationLocation.ToString.Trim)), System.Net.HttpWebRequest)
UploadRequest.Credentials = Credential
UploadRequest.Timeout = 60000000
UploadRequest.Method = "PUT"
UploadRequest.ContentLength = New
System.IO.FileInfo(SourceLocation.ToString.Trim).L ength
FileSize = UploadRequest.ContentLength.ToString.Trim
'To set Upload Stream settings
Dim SourceStream As New
System.IO.FileStream(SourceLocation.ToString.Trim, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
Dim RequestStream As System.IO.Stream =
UploadRequest.GetRequestStream()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0,
CurLocation As Integer = 0
Position = SourceStream.Read(Buffer, 0, Buffer.Length)

While Position <> 0
RequestStream.Write(Buffer, 0, Position)
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
CurLocation += Position
End While

'To upload Stream on Remote system
Dim WebResponse As System.Net.HttpWebResponse =
CType(UploadRequest.GetResponse(), System.Net.HttpWebResponse)
Dim ResponseReader As New
System.IO.StreamReader(WebResponse.GetResponseStre am())
Response = ResponseReader.ReadToEnd()
UploadFile = True

RequestStream.Close()
UploadRequest = Nothing
SourceStream = Nothing
RequestStream = Nothing
WebResponse = Nothing
ResponseReader = Nothing
ElseIf SourceLocation.ToString.Trim = "" Then
Call MsgBox("Source Location is missing")
ElseIf DestinationLocation.ToString.Trim = "" Then
Call MsgBox("Destination Location is missing")
End If
Catch ex As Exception
Call MsgBox(ex.ToString)
End Try
End Function
--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"David B" <Da****@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
I'm looking for guidance to show developers information about implementing
https using VB so that an application which needs to transfer files
securely
from within a VB client app can do so using https:

I'm aware the capability is available but need some guidance about where
to
find the detailed information so I can help a developer learn something
they
do not already know how to do.

Any help appreciated.

Feb 19 '06 #2
Hi. Thanks for this response.

I presume with just a little effort we could reverse the direction of this
example and have this work for downloading a file TO a client with this
function in the client-side app? (The PUT becomes a GET, etc?).

Again, trying to provide guidance to the developers for them to work this out.

"vbnetdev" wrote:
Hi David,

Play with this....

Dim crdential As New System.Net.NetworkCredential("UserName", "Password")
UploadFile("c:\mylocalfolder\mylocalfile.txt",
"https://thewebsite.com/thedirectory/mylocalfile.txt", crdential)

----------------------------------
Friend Function UploadFile(ByVal SourceLocation As String, ByVal
DestinationLocation As String, ByVal Credential As
System.Net.NetworkCredential) As Boolean
Dim Response As String = Nothing, FileSize As Double = 0
Try
UploadFile = False
If SourceLocation.ToString.Trim <> "" And
DestinationLocation.ToString.Trim <> "" Then
'To set Upload settings
Dim UploadRequest As System.Net.HttpWebRequest =
CType(System.Net.WebRequest.Create(New
Uri(DestinationLocation.ToString.Trim)), System.Net.HttpWebRequest)
UploadRequest.Credentials = Credential
UploadRequest.Timeout = 60000000
UploadRequest.Method = "PUT"
UploadRequest.ContentLength = New
System.IO.FileInfo(SourceLocation.ToString.Trim).L ength
FileSize = UploadRequest.ContentLength.ToString.Trim
'To set Upload Stream settings
Dim SourceStream As New
System.IO.FileStream(SourceLocation.ToString.Trim, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
Dim RequestStream As System.IO.Stream =
UploadRequest.GetRequestStream()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0,
CurLocation As Integer = 0
Position = SourceStream.Read(Buffer, 0, Buffer.Length)

While Position <> 0
RequestStream.Write(Buffer, 0, Position)
Position = SourceStream.Read(Buffer, 0, Buffer.Length)
CurLocation += Position
End While

'To upload Stream on Remote system
Dim WebResponse As System.Net.HttpWebResponse =
CType(UploadRequest.GetResponse(), System.Net.HttpWebResponse)
Dim ResponseReader As New
System.IO.StreamReader(WebResponse.GetResponseStre am())
Response = ResponseReader.ReadToEnd()
UploadFile = True

RequestStream.Close()
UploadRequest = Nothing
SourceStream = Nothing
RequestStream = Nothing
WebResponse = Nothing
ResponseReader = Nothing
ElseIf SourceLocation.ToString.Trim = "" Then
Call MsgBox("Source Location is missing")
ElseIf DestinationLocation.ToString.Trim = "" Then
Call MsgBox("Destination Location is missing")
End If
Catch ex As Exception
Call MsgBox(ex.ToString)
End Try
End Function
--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"David B" <Da****@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
I'm looking for guidance to show developers information about implementing
https using VB so that an application which needs to transfer files
securely
from within a VB client app can do so using https:

I'm aware the capability is available but need some guidance about where
to
find the detailed information so I can help a developer learn something
they
do not already know how to do.

Any help appreciated.


Feb 20 '06 #3
Are you asking me to come up with a sample to do this? I don't imagine it
would be difficult. The reason I gave you what I did was if you are trying
to get your developers a starting point this should do it.

If you are asking for someone to build it for them you need to email me off
list (ad***@nospamkjmsolutions.com (remove no spam)) to discuss this
situation further.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"David B" <Da****@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com...
Hi. Thanks for this response.

I presume with just a little effort we could reverse the direction of this
example and have this work for downloading a file TO a client with this
function in the client-side app? (The PUT becomes a GET, etc?).

Again, trying to provide guidance to the developers for them to work this
out.

"vbnetdev" wrote:
Hi David,

Play with this....

Dim crdential As New System.Net.NetworkCredential("UserName", "Password")
UploadFile("c:\mylocalfolder\mylocalfile.txt",
"https://thewebsite.com/thedirectory/mylocalfile.txt", crdential)

----------------------------------
Friend Function UploadFile(ByVal SourceLocation As String, ByVal
DestinationLocation As String, ByVal Credential As
System.Net.NetworkCredential) As Boolean
Dim Response As String = Nothing, FileSize As Double = 0
Try
UploadFile = False
If SourceLocation.ToString.Trim <> "" And
DestinationLocation.ToString.Trim <> "" Then
'To set Upload settings
Dim UploadRequest As System.Net.HttpWebRequest =
CType(System.Net.WebRequest.Create(New
Uri(DestinationLocation.ToString.Trim)), System.Net.HttpWebRequest)
UploadRequest.Credentials = Credential
UploadRequest.Timeout = 60000000
UploadRequest.Method = "PUT"
UploadRequest.ContentLength = New
System.IO.FileInfo(SourceLocation.ToString.Trim).L ength
FileSize = UploadRequest.ContentLength.ToString.Trim
'To set Upload Stream settings
Dim SourceStream As New
System.IO.FileStream(SourceLocation.ToString.Trim,
System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)
Dim RequestStream As System.IO.Stream =
UploadRequest.GetRequestStream()
Dim Buffer(4095) As Byte
Dim Position As Integer = 0, ivlLoop As Integer = 0,
CurLocation As Integer = 0
Position = SourceStream.Read(Buffer, 0, Buffer.Length)

While Position <> 0
RequestStream.Write(Buffer, 0, Position)
Position = SourceStream.Read(Buffer, 0,
Buffer.Length)
CurLocation += Position
End While

'To upload Stream on Remote system
Dim WebResponse As System.Net.HttpWebResponse =
CType(UploadRequest.GetResponse(), System.Net.HttpWebResponse)
Dim ResponseReader As New
System.IO.StreamReader(WebResponse.GetResponseStre am())
Response = ResponseReader.ReadToEnd()
UploadFile = True

RequestStream.Close()
UploadRequest = Nothing
SourceStream = Nothing
RequestStream = Nothing
WebResponse = Nothing
ResponseReader = Nothing
ElseIf SourceLocation.ToString.Trim = "" Then
Call MsgBox("Source Location is missing")
ElseIf DestinationLocation.ToString.Trim = "" Then
Call MsgBox("Destination Location is missing")
End If
Catch ex As Exception
Call MsgBox(ex.ToString)
End Try
End Function
--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"David B" <Da****@discussions.microsoft.com> wrote in message
news:7B**********************************@microsof t.com...
> I'm looking for guidance to show developers information about
> implementing
> https using VB so that an application which needs to transfer files
> securely
> from within a VB client app can do so using https:
>
> I'm aware the capability is available but need some guidance about
> where
> to
> find the detailed information so I can help a developer learn something
> they
> do not already know how to do.
>
> Any help appreciated.
>


Feb 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kiran | last post by:
Hi, I hosted a PHP project on my web server(IIS) and I am accessing the ip addres through my office public address like this: (example) https://61.95.204.43:8887/phptest/test.php ...
2
by: Craig Keightley | last post by:
i have the following script on my checkout page to check if https is set in the address bar: if ($_SERVER != "on") { $url = $_SERVER; $query = $_SERVER; $path = $_SERVER; header("Location:...
16
by: Paul Sweeney | last post by:
Does anyone know of a working (python) https proxy which allows viewing of unencrypted data being sent from my browser to an https site? I've worked my way through most on the list at...
14
by: Peter Chant | last post by:
I'm currently authenticating a site I have built using basic http authentication built into apache. This has zero overhead on php which is a bonus but it seems to not quite work how I'd like. ...
4
by: Jason P | last post by:
Basically we have a web method with a dynamic URL. The client is developed in C++ and I've been using the webReference.SetUrl( "http://test.example.com..." ) method successfully with various web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.