|
i thought exception hiding is doing like this
catch (Exception ex)
{
}
and i'm not sure what specific exception will happen so i used the general exception
thanks
|
|
|
|
|
|
An approach could be to put the SQLException within the Save() method and the general exception outside - that way SQLExceptions are caught in the Save method and anything else outside.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
In the example given, the second way is probably better -- I wouldn't want to call your Save method from a Windows Service and have it try to pop up a message.
|
|
|
|
|
Hi all,
I have two users on my system. On one user I could edit the Key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies
But on second user I could not do so. Just getting the error message
"Cannot create value: Error writing to the registry.".
When I tried to change permissions on above key, I get error message
"Unable to save permission changes on Policies.Access is denied.".
I am wondering why same user cannot change its own above registry key. Can somebody help me please how to do so via both "Registry Editor" and via a program in C#?
Second help I need is How to change above key of a different user (I mean changing above key of user A from user B's logged-in session) programmatically (preferably via C#).
I am trying this on XP right now but will need to run my program on XP, VISTA and Windows 7.
If somebody knows how to go about it, please help me in that.
Thanks in Advance
Best Regards
Aseem
modified on Sunday, March 28, 2010 5:34 AM
|
|
|
|
|
You did not say which version of Windows you are running on, but this is probably a permissions issue. Try running the program with Administrator privilege and see if that fixes the issue.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Dear All,
I need to know whether Entity Framework works with all of the major database server like- sql, oracle, mysql
and so on.
mir
|
|
|
|
|
|
mmdullah wrote: all of the major database server like- sql
No, Microsoft made an object relational mapping database tool that does not work with any know database
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Dear All,
There are numerous sample of SMS sending and reading on web.
But I need to dial a mobile phone and a conversation period .
In this period I want to record the conversation .
Would you please give me any idea?
Mir
|
|
|
|
|
Have you tried to write or plan any code? How can we help you if you've not done some steps?
If the post was helpful, please vote, eh!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
mmdullah wrote: Would you please give me any idea?
Search for "TAPI"
I are Troll
|
|
|
|
|
I am using this code after your modification to reduce the image size and save the reduced image into the xml file but it's still saving the large image not the reduced image. I tried using the reduced_image but it's not working..
picturePhoto.Image = System.Drawing.Image.FromFile(dialogPhoto.FileName);
Graphics reduced_images = Graphics.FromImage(Image.FromFile(dialogPhoto.FileName));
reduced_images.DrawImage(picturePhoto.Image, 0, 0, 200, 300);
memory_stream = new MemoryStream();
picturePhoto.Image.Save(memory_stream, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] imageBytes = memory_stream.ToArray();
xml_document.GetElementsByTagName("Photo")[0].InnerText = Convert.ToBase64String(imageBytes);
xml_document.Save(public_var.file_name);
|
|
|
|
|
To resize an image,
var originalImage = Bitmap.FromFile(imagePath);
var resizedImage = new Bitmap(originalImage, newWidth, newHeight);
I don't know about your requirements but I suggest you look into using a database but if you need to use an xml file may I suggest you save the images to disk and store the paths (relative paths) in the xml file since you'd be storing about 59 KB inside the xml file for each image which may increase the time required to parse the xml file and may make the xml file hit the size limit of the file system if you're storing a lot of images. Again, it's all about the requirements and what would be needed to be implemented in the future of the application.
Eslam Afifi
|
|
|
|
|
actually i need to be in XML not database
|
|
|
|
|
jrahma wrote: picturePhoto.Image = System.Drawing.Image.FromFile(dialogPhoto.FileName);
Graphics reduced_images = Graphics.FromImage(Image.FromFile(dialogPhoto.FileName));
that is creating two images, i.e. two distinct instances of the Image class, each holding the same picture.
No wonder you will get confused.
Furthermore, you should keep the image in a variable, as images need to be disposed of when done.
|
|
|
|
|
Luc Pattyn wrote: Furthermore, you should keep the image in a variable, as images need to be disposed of when done
I'm fiddling with a gallery creation web page, I have the images in a folder but do not have any thumbnails. I wrote a loop through a datatable of image names and check for a thumb, creating a new thumb if it is missing.
I get an outofmemory exception on the second thumb creation, I presume this is potentially caused by not disposing of the image!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yes,
rather than
Graphics reduced_images = Graphics.FromImage(Image.FromFile(dialogPhoto.FileName));
...
reduced_images.Dispose();
it should be
Image img=Image.FromFile(dialogPhoto.FileName);
Graphics reduced_images = Graphics.FromImage(img);
...
reduced_images.Dispose();
img.Dispose();
so both the Graphics and the Image instance get disposed of, keeping you out of OOM trouble.
BTW: using a using construct would make it a bit more elegant.
|
|
|
|
|
Thanks Luc
Luc Pattyn wrote: using a using construct would make it a bit more elegant.
I rarely need an object for a really short period and forever forget the use using, this obviously lends itself to that model, thanks for the reminder!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You're welcome.
PS: even when using doesn't fit the application, don't forget to dispose of long lived DataTables!
|
|
|
|
|
Is it possible to have one XMLDocument for all MDI Children so that I only need to invoke the .save once from MDI container instead of doing it every time in every child?
|
|
|
|
|
|
You sound like you need to consider using the Observer pattern:
With all the children being registered observers, you just need to fire up the save method in the object (MDI form) and it'll take care of saving the other forms.
If the post was helpful, please vote, eh!
Current activities:
Book: Devils by Fyodor Dostoyevsky
Project: Hospital Automation, final stage
Learning: Image analysis, LINQ
Now and forever, defiant to the end.
What is Multiple Sclerosis[ ^]?
|
|
|
|
|
I have a class called save_changes() in evey MDI child... How can I run that class for every open MDI when I click a button on my MDI parent?
|
|
|
|
|
Well, you can loop over the MdiChildren collection and call that save_changes method on each one.
Eslam Afifi
|
|
|
|