Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everybody,


Currently am working on asp.net. i am trying to create screenshot. i used the below code. thats working but i want to remove the hard coded values.

Here is my code.

C#
using (Bitmap target = new Bitmap(1000,1000))
        {
            using (Graphics g = Graphics.FromImage(target))
            {
                g.CopyFromScreen(0, 0, 0, 0, new Size(1000, 1000));
            }
            target.Save("D:\\Screen.JPEG", ImageFormat.Bmp);
        }


from the above code i want to remove the hard coded values like 1000,

Otherwise give me alternative solution.

help me.

Thanks in advance.
Posted
Updated 21-Jan-12 1:20am
v2

1 solution

You do realize that if you are really using ASP.NET as you say, that will take a picture of the SERVER screen, not the CLIENT?
That it works on your development PC because it is acting as both server and client?
That it won't come close to what you probably want in production?

Or is this actually Winforms?
 
Share this answer
 
Comments
naveenvenkanna 23-Jan-12 0:33am    
Thank you for replay,

As you said if it works on development PC how can i take the picture of the SERVER?

Help me.
OriginalGriff 23-Jan-12 4:11am    
If you run server code in your website, it always runs on the server - only the javascript (or similar) runs on the client. So any and all C# code you write in your project gets executed on the SERVER not the CLIENT. So a picture of the desktop will be the server desktop, and a MessageBox.Show will cause a box to appear on the server (and annoy the heck out of the server admin staff)

When you run the code on your development machine, it acts as both server and client.
naveenvenkanna 23-Jan-12 7:39am    
k fine, then how can i take client's desktop picture. please guide me in the right direction. i had that type of requirement.
OriginalGriff 23-Jan-12 8:12am    
You can't.
Security will not allow you to do that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900