By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,957 Members | 1,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,957 IT Pros & Developers. It's quick & easy.

Can somebody put this VB code into c#?

P: n/a
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

Nov 14 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Sunfire" <a_*****@sbcglobal.netwrote in message
news:ub**************@TK2MSFTNGP05.phx.gbl...
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).
Nov 14 '07 #2

P: n/a
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" <ea******************************@poblacion.orgwro te
in message news:%2****************@TK2MSFTNGP02.phx.gbl...
"Sunfire" <a_*****@sbcglobal.netwrote in message
news:ub**************@TK2MSFTNGP05.phx.gbl...
>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).


Nov 14 '07 #3

P: n/a
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:
"Sunfire" <a_*****@sbcglobal.netwrote in message
news:ub**************@TK2MSFTNGP05.phx.gbl...
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).
Nov 14 '07 #4

P: n/a
On Nov 14, 4:06 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
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

Nov 14 '07 #5

P: n/a
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:
On Nov 14, 4:06 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
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

Nov 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.