PC Review


Reply
Thread Tools Rate Thread

Can somebody put this VB code into c#?

 
 
Sunfire
Guest
Posts: n/a
 
      14th Nov 2007
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



 
Reply With Quote
 
 
 
 
Alberto Poblacion
Guest
Posts: n/a
 
      14th Nov 2007
"Sunfire" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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).


 
Reply With Quote
 
Sunfire
Guest
Posts: n/a
 
      14th Nov 2007
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-(E-Mail Removed)> wrote
in message news:%(E-Mail Removed)...
> "Sunfire" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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).
>
>



 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      14th Nov 2007
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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).
>
>
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      14th Nov 2007
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

 
Reply With Quote
 
=?Utf-8?B?RGF2aWQgQW50b24=?=
Guest
Posts: n/a
 
      14th Nov 2007
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
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linq to XML--Are there code examples that make Linq as easy as SQL? Or how can I convert ths simple pseudo code into real code? Reece Microsoft C# .NET 4 10th Dec 2008 03:13 AM
ATI Radeon Drivers - Code 43, Code 37 & Code 10 =?Utf-8?B?SmFrZQ==?= Windows Vista Hardware 14 29th Aug 2006 05:50 AM
ATI Display Drivers - Code 43, Code 37, Code 10 Jake Windows Vista Hardware 2 8th Jul 2006 04:00 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb Microsoft ASP .NET 1 29th Mar 2006 02:00 AM
[New] Zipoid - ZIP Code, City Name and Area Code Lookup - Zip Code to Zip Code Distance Calculation Mel Freeware 0 22nd Jul 2005 04:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:20 PM.