Connecting Tech Pros Worldwide Help | Site Map

Can somebody put this VB code into c#?

Sunfire
Guest
 
Posts: n/a
#1: Nov 14 '07
Can somebody put this code into c#?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim imageFolder As String
Dim imageText As String
Dim bm As Bitmap
Dim ms As MemoryStream

imageFolder = Request.QueryString(imFolder)
imageText = Request.QueryString(imText)

If imageFolder Is Nothing Then
bm = makeImage(imageText)
Else
bm = makeImage(imageFolder, imageText)
End If

ms = New MemoryStream
bm.Save(ms, ImageFormat.Jpeg)
Response.ContentType = "image/jgp"
Response.BinaryWrite(ms.ToArray())
End Sub



Alberto Poblacion
Guest
 
Posts: n/a
#2: Nov 14 '07

re: Can somebody put this VB code into c#?


"Sunfire" <a_borka@sbcglobal.netwrote in message
news:ubcF9nrJIHA.5328@TK2MSFTNGP05.phx.gbl...
Quote:
Can somebody put this code into c#?
>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim imageFolder As String
Dim imageText As String
Dim bm As Bitmap
Dim ms As MemoryStream
>
imageFolder = Request.QueryString(imFolder)
imageText = Request.QueryString(imText)
>
If imageFolder Is Nothing Then
bm = makeImage(imageText)
Else
bm = makeImage(imageFolder, imageText)
End If
>
ms = New MemoryStream
bm.Save(ms, ImageFormat.Jpeg)
Response.ContentType = "image/jgp"
Response.BinaryWrite(ms.ToArray())
End Sub

You can enlist the help of an automatic converter such as the one at
http://labs.developerfusion.co.uk/co...to-csharp.aspx.


protected void Page_Load(object sender, System.EventArgs e)
{
string imageFolder;
string imageText;
Bitmap bm;
MemoryStream ms;

imageFolder = Request.QueryString[imFolder];
imageText = Request.QueryString[imText];

if (imageFolder == null) {
bm = makeImage(imageText);
}
else {
bm = makeImage(imageFolder, imageText);
}

ms = new MemoryStream();
bm.Save(ms, ImageFormat.Jpeg);
Response.ContentType = "image/jgp";
Response.BinaryWrite(ms.ToArray());
}


While we are at it, it is worth noting that this is not an efficient way to
serve an image from a file. It is better to use an HttpHandler (.ashx)
instead of a WebForm (.aspx).


Sunfire
Guest
 
Posts: n/a
#3: Nov 14 '07

re: Can somebody put this VB code into c#?


Actually, the code was given to me by somebody else. It was an example of
how to try and securely serve streaming mp3 files by refusing the ability to
download them. The person just used images as an example. Is there any
better way of how to do this without using flash?
"Alberto Poblacion" <earthling-quitaestoparacontestar@poblacion.orgwrote
in message news:%2363QNIsJIHA.3672@TK2MSFTNGP02.phx.gbl...
Quote:
"Sunfire" <a_borka@sbcglobal.netwrote in message
news:ubcF9nrJIHA.5328@TK2MSFTNGP05.phx.gbl...
Quote:
>Can somebody put this code into c#?
>>
>Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>System.EventArgs) Handles Me.Load
>Dim imageFolder As String
>Dim imageText As String
>Dim bm As Bitmap
>Dim ms As MemoryStream
>>
>imageFolder = Request.QueryString(imFolder)
>imageText = Request.QueryString(imText)
>>
>If imageFolder Is Nothing Then
>bm = makeImage(imageText)
>Else
>bm = makeImage(imageFolder, imageText)
>End If
>>
>ms = New MemoryStream
>bm.Save(ms, ImageFormat.Jpeg)
>Response.ContentType = "image/jgp"
>Response.BinaryWrite(ms.ToArray())
>End Sub
>
>
You can enlist the help of an automatic converter such as the one at
http://labs.developerfusion.co.uk/co...to-csharp.aspx.
>
>
protected void Page_Load(object sender, System.EventArgs e)
{
string imageFolder;
string imageText;
Bitmap bm;
MemoryStream ms;
>
imageFolder = Request.QueryString[imFolder];
imageText = Request.QueryString[imText];
>
if (imageFolder == null) {
bm = makeImage(imageText);
}
else {
bm = makeImage(imageFolder, imageText);
}
>
ms = new MemoryStream();
bm.Save(ms, ImageFormat.Jpeg);
Response.ContentType = "image/jgp";
Response.BinaryWrite(ms.ToArray());
}
>
>
While we are at it, it is worth noting that this is not an efficient way
to serve an image from a file. It is better to use an HttpHandler (.ashx)
instead of a WebForm (.aspx).
>
>

=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
 
Posts: n/a
#4: Nov 14 '07

re: Can somebody put this VB code into c#?


And you'll also need the event wireup code somewhere ('Page_Init' perhaps):
this.Load += new System.EventHandler(Page_Load);

--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to C++/CLI
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI


"Alberto Poblacion" wrote:
Quote:
"Sunfire" <a_borka@sbcglobal.netwrote in message
news:ubcF9nrJIHA.5328@TK2MSFTNGP05.phx.gbl...
Quote:
Can somebody put this code into c#?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim imageFolder As String
Dim imageText As String
Dim bm As Bitmap
Dim ms As MemoryStream

imageFolder = Request.QueryString(imFolder)
imageText = Request.QueryString(imText)

If imageFolder Is Nothing Then
bm = makeImage(imageText)
Else
bm = makeImage(imageFolder, imageText)
End If

ms = New MemoryStream
bm.Save(ms, ImageFormat.Jpeg)
Response.ContentType = "image/jgp"
Response.BinaryWrite(ms.ToArray())
End Sub
>
>
You can enlist the help of an automatic converter such as the one at
http://labs.developerfusion.co.uk/co...to-csharp.aspx.
>
>
protected void Page_Load(object sender, System.EventArgs e)
{
string imageFolder;
string imageText;
Bitmap bm;
MemoryStream ms;
>
imageFolder = Request.QueryString[imFolder];
imageText = Request.QueryString[imText];
>
if (imageFolder == null) {
bm = makeImage(imageText);
}
else {
bm = makeImage(imageFolder, imageText);
}
>
ms = new MemoryStream();
bm.Save(ms, ImageFormat.Jpeg);
Response.ContentType = "image/jgp";
Response.BinaryWrite(ms.ToArray());
}
>
>
While we are at it, it is worth noting that this is not an efficient way to
serve an image from a file. It is better to use an HttpHandler (.ashx)
instead of a WebForm (.aspx).
>
>
>
Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#5: Nov 14 '07

re: Can somebody put this VB code into c#?


On Nov 14, 4:06 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
Quote:
And you'll also need the event wireup code somewhere ('Page_Init' perhaps):
this.Load += new System.EventHandler(Page_Load);
Unless you've got auto-event wireup, of course...

Jon

=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
 
Posts: n/a
#6: Nov 14 '07

re: Can somebody put this VB code into c#?


Right, but since the original VB code used 'Handles', autoeventwireup is
likely turned off.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to C++/CLI
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI


"Jon Skeet [C# MVP]" wrote:
Quote:
On Nov 14, 4:06 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
Quote:
And you'll also need the event wireup code somewhere ('Page_Init' perhaps):
this.Load += new System.EventHandler(Page_Load);
>
Unless you've got auto-event wireup, of course...
>
Jon
>
>
Closed Thread


Similar C# / C Sharp bytes