Click here to Skip to main content
15,843,145 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi all,

I am taking screen shot of the page and saving in a file in the server.
in my Local Machine it works fine. but when i hosted in server ,

got exception
HTML
"Handle is Invalid"


then tried saving the image in DB. here too in local image is stored and retrieved. but in hosted site only block screen is displayed.


i have used this code



C#
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
           Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
           graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
           bitmap.Save( System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "Uploads\\myscreenshot.bmp", ImageFormat.Bmp);



How to resolve this?




Thanks in Advance...
Posted
Updated 24-Jan-12 23:42pm
v2
Comments
Sergey Alexandrovich Kryukov 25-Jan-12 2:09am    
Not enough information. What did you try?
--SA

Hi,

Not sure..but are you missing back slash in building the adress infront if upload??

C#
bitmap.Save( System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\Uploads\\myscreenshot.bmp", ImageFormat.Bmp); 


Hope it helps.
 
Share this answer
 
Comments
palraj001 25-Jan-12 4:53am    
no . it works in local system. problem is in hoster server
manognya kota 25-Jan-12 5:01am    
What is the exact exception that you are getting in the trace ? apart from the handle invalid error.
manognya kota 25-Jan-12 5:23am    
Hi,

try this code to take the custom path of the image.

SaveFileDialog saveDialog = new SaveFileDialog();
saveDialog.Filter = "JPeg Image|*.jpg";
saveDialog.Title = "Save Image as";
saveDialog.ShowDialog();
if (saveDialog.FileName != string.Empty)
bitmap.Save(saveDialog.FileName, ImageFormat.Jpeg);
Go through this link , this may helps you

Here[^]

Thanks
--RA
 
Share this answer
 

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