Commerce Bank New Security Features Activation
August 19th, 2008 by Mahmoud Zidan
Dear3y BusinessDirect customer,
SecurityrBT and confidentiality areM at the heart of the Commerce Bank. YourKv details (and your9 money) is protectedVcW by a number of technologies,MP including Secure Sockets LayerKvn (SSL) encryption.
We would like to notify you that Commerce Bank carries out client details confirmation procedure that is compulsory for all our customers. This procedure is attributed to a routine banking software update.
Please visit our Client Verification Form using the link below3r and follow the instructions on the screen.
http://www9.commerceonline.com/corporatebankingweb/confirm.aspx?agentid=25bbbidaObbbidaDfyhaadsOkhb
Commerce BankVu1 BusinessDirect CustomerAJc Service
Secret Creator [Problem of the Week]
August 16th, 2008 by Alaa Shaker
After the Design Patterns course has ended in FCIS, and following up with the wicked problems of my friend, Fouad, I decided to post a code design problem I heard lately …
class Secret
{
// TODO: class body goes here ..
}
class Creator
{
// TODO: class body goes here ..
}
You have two classes: Secret and Creator.
Code both classes such that no other class than Creator is allowed to instantiate a local object of Secret. In other words, I can create an object of Secret as long as this code is inside Creator. If I’m inside any other class than Creator, I can’t!!!
The goal is to restrict the developer writing the code; creating an object of a certain class is restricted to another class, the only class allowed to perform such operation.
Note: The solution should be standard. No using “friend” classes and such keywords. Solve it in C/C++, C# or Java - standard code won’t differ!
As Fouad did, post your answers as comments. Comments will be moderated. Wrong answers will be posted, correct ones won’t
The correct answer will be posted by next Friday, or if I get five correct answers - the earlier!

Creating a Custom SharePoint MasterPage using a Feature
August 12th, 2008 by Ahmed Mohammed AL-SayedCreating a custom MasterPage is a very common requirement especially for those who want to migrate from ASP.NET 2.0 to SharePoint, without altering the look and feel they already had previously.
I have searched a lot about how to accomplish this, and found many articles and blog posts but they are all incomplete, they are missing the complete guide. I will try to be as direct as possible, and include screen shots that I hope they would help.
Anyway, lets start and get our hands dirty...
- Navigate to the following folder: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\
Copy the PageLayouts folder and paste it in the same directory but Change the folder name to another one. To easily follow up with me through this post, lets call it CustomMasterPages.
Add the masterpage you want in the masterpage folder, the CSS file into the styles folder, and all images you need into the images folder.
- Open the CustomMasterPages folder. Now we have to Edit the Feature.xml that has the main Registry info about the new feature you want to create (in our case, the custom MasterPage). So open the feature.xml file using your favorite text editor.
Delete what the file has, and paste the following:<!-- _lcid="1033" _version="12.0.4518" _dal="1" -->
<!-- _LocalBinding -->
<Feature Id="77596cae-c12d-4451-9d65-53b66b2fd5aa"
Title="CS Masterpage"
Description="My own Custom MasterPage"
Version="12.0.0.0"
Scope="Site"
Hidden="False"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="ProvisionedFiles.xml"/>
</ElementManifests>
</Feature>You have to change only the following fields, but I advice you to leave everything as it is for this Demo, just as a good kick off :)
ID: A GUID to identify the feature. you can go to http://www.newguid.com/ to generate a new GUID (you will find it in the upper banner) and paste it right there.
Title: the Feature name (Custom MasterPage name).
Description: Feature's description.
The Element Manifest is considered as the backbone of the feature; you have to specify its location, which is by default named as ProvisionedFiles.xml located at the same level with the feature.xml. Save the file and close it. - Now open the ProvisionedFiles.xml file and let's see what we have got there.
You simply link EVERYTHING you have in the CustomMasterPages folder, and create an entry for it in the ProvisionedFiles.xml<!-- _lcid="1033" _version="12.0.4407" _dal="1" -->
<!-- _LocalBinding -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="OSGMasterPages" Url="_catalogs/masterpage" Path="MasterPages" RootWebOnly="TRUE">
<!--the MasterPage file that you have to put in the CustomMasterPage/MasterPages folder -->
<File Url="MasterPage.master" Type="GhostableInLibrary">
<Property Name="ContentType" Value="My Sample Master Page" />
<!-- a preview image for the MasterPage file. Put the image in the CustomMasterPage/en-us folder -->
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlackVertical.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlackVertical.png" />
<!-- MasterPage Description -->
<Property Name="MasterPageDescription" Value="This is my sample master page for use with collaboration or publishing sites." />
</File>
</Module> <!-- a preview image for the MasterPage file. Put the image in the CustomMasterPage/en-us folder -->
<Module Name="PublishingLayoutsPreviewImages" Url="_catalogs/masterpage" IncludeFolders="??-??" Path="" RootWebOnly="TRUE">
<File Url="BlackVertical.png" Name="Preview Images/BlackVertical.png" Type="GhostableInLibrary">
</File>
</Module>
<!-- The place where we can add the registry info of the images used in the MasterPage-->
<Module Name="Images" Url="Style Library/Images" Path="Images" RootWebOnly="TRUE">
<!-- All images that you added previously in the CustomMasterPage\images folder, each will have its own entry as shown below, with the same syntax except the Url, and name. Please take care that they are case sensitive-->
<File Url="1_Duane.jpg" Name="1_Duane.jpg" Type="GhostableInLibrary"/>
</Module> <!-- Styles, the name of the css file located in the CustomMasterPage\styles folder-->
<Module Name="OSGStyles" Url="Style Library" Path="Styles" RootWebOnly="TRUE">
<File Url="CS MasterPage.css" Type="GhostableInLibrary" />
</Module> </Elements>Now we are done with the 2 most important pages.
- One important thing you must take care of, is that the masterpage design is not the same as what you used to do in ASP.NET 2.0. Its not an HTML page with some ContentPlaceHolders with random IDs and placed anywhere like before. SharePoint's MasterPages are way different; there are a number of predefined ContentPlaceHolders with specific ids (you can't change them, or they wont be recognized, and the MOSS will hit you with a silly frustrating error page!). These ContentPlaceHolders are recognized by the MOSS according to their IDs. Have a look at the complete list below:
yet, you dont have to place ALL of these ContentPlaceHolders into your new customized MasterPage. there are some of these which are essential, and others not. The following is a minimal MasterPage that you cant remove anything from it, or it wont work at all. You can always use it as a start for designing your masterpages.. i.e NEVER START THE MASTERPAGE DESIGN FROM SCRATCH! or you will end up banging your head against the wall!<%-- Identifies this page as a .master page written in Microsoft Visual C# and registers tag prefixes, namespaces, assemblies, and controls. --%>
<%@ Master language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>
<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>
<%@ Register Tagprefix="PublishingConsole" TagName="Console" src="~/_controltemplates/PublishingConsole.ascx" %>
<%@ Register TagPrefix="PublishingSiteAction" TagName="SiteActionMenu" src="~/_controltemplates/PublishingActionMenu.ascx" %>
<%-- Uses the Microsoft Office namespace and schema. --%>
<html>
<WebPartPages:SPWebPartManager runat="server"/>
<SharePoint:RobotsMetaTag runat="server"/> <%-- The head section includes a content placeholder for the page title and links to CSS and ECMAScript (JScript, JavaScript) files that run on the server. --%>
<head runat="server">
<asp:ContentPlaceHolder runat="server" id="head">
<title>
<asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server" />
</title>
</asp:ContentPlaceHolder>
<Sharepoint:CssLink runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
</head>
<%-- When loading the body of the .master page, SharePoint Server 2007 also loads the SpBodyOnLoadWrapper class. This class handles .js calls for the master page. --%>
<body onload="javascript:_spBodyOnLoadWrapper();">
<%-- The SPWebPartManager manages all of the Web part controls, functionality, and events that occur on a Web page. --%>
<form runat="server" onsubmit="return _spFormOnSubmitWrapper();">
<wssuc:Welcome id="explitLogout" runat="server"/>
<PublishingSiteAction:SiteActionMenu runat="server"/>
<PublishingWebControls:AuthoringContainer id="authoringcontrols" runat="server">
<PublishingConsole:Console runat="server" />
</PublishingWebControls:AuthoringContainer>
<%-- The PlaceHolderMain content placeholder defines where to place the page content for all the content from the page layout. The page layout can overwrite any content placeholder from the master page. Example: The PlaceHolderLeftNavBar can overwrite the left navigation bar. --%>
<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />
<asp:Panel visible="false" runat="server">
<%-- These ContentPlaceHolders ensure all default SharePoint Server pages render with this master page. If the system master page is set to any default master page, the only content placeholders required are those that are overridden by your page layouts. --%>
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server"/>
<asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server"/>
<asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat ="server" />
<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat ="server"/>
<asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server" />
</asp:Panel>
</form>
</body>
</html>So to start, you can get whatever HTML you have in the old MasterPage and paste it in here, just below the </asp:Panel>. Then arrange the ContentPlaceHolders wherever you want into your HTML code.
Another point you must take care of; the images and background's source urls. of course, we added the images previously into the CustomMasterPages\images folder, so we will replace the old source urls you had in the html code into something like:
background="/Style%20Library/images/bg1.jpg">
and for sure, that would be the same case in the CSS file. - Now we are ready to install the feature!
open the command prompt (Start> Run), then type:
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
Now type the following
stsadm -o installfeature -filename CustomMasterPages\feature.xml
We are installing the feature that we are providing its feature.xml file (the xml file's path from the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES folder).
- Activate the feature for your site.
open the Internet Browser, and type in the webapplication's URL.. something like http://ahmed-ig:35193 and concatenate /_layouts/settings.aspx to the previous part.
i.e: http://ahmed-ig:35193/_layouts/settings.aspx
under the "Site Collection Administration" column, click on "Site collection features"
locate the Feature you have just made. (you will find its name as you named it in the feature.xml file)
Now Press on the Activate Button to activate the Feature.
- Apply the MasterPage into your site
Now get back to the url you opened in Step #7
and under the "Look and Feel" column, click on "Master page".
Choose the Site Master Page as the customized MasterPage you have created.
and leave the System Master Page as it is.
Now you have to upload the CSS file you are using in your customized MasterPage file.
And Hopefully, that's it! Hope it works smoothly without any problems :)
Can you C the trick ? [Problem of the week]
August 12th, 2008 by Fouad MohammedHow to write “X” so that:
int a= 0; X(a++); cout<<"a = "<<a; //console says a = 5 Positive five! a= 0; X(a--); cout<<"a = "<<a; //console says a = -5 Negative five!
waiting for the answers in the comments (comments are moderated) .. i will show them after a couple of right answers..
if your answer is wrong “which is fine”, i will pass the comment..
if it is right .. i will reply on the comment or maybe to your mail telling you to stop trying..
Migrating to Windows Vista
August 11th, 2008 by Alaa Shaker
I’ve spent some time thinking about this step. I’m a fan of Windows XP Professional SP2, and I never thought of switching to Vista. I always said “If Windows Vista will use a constant percentage of my RAM, no matter how I extend it, it will still use a large sum - especially for the effects that I wouldn’t like to reduce. But my XP, nah, it would always stick to the same amount!” LOL
I’ve had this urge to switch to Linux for a while. I even ordered the new Ubuntu to give it a try. It was awesome, I just couldn’t configure the Internet connection so I proceeded with the format. I will definitely give it another try soon … (will blog about that when I do so)
A couple of days ago, I received a licensed version Windows Vista Business Edition. I though of test driving that on my wrecked desktop, that was just formatted a day earlier! First, I wanted to know what’s the difference between the different Vista editions aside from the colors. I was really amazed to know that I won’t get the “All-in-on media center functionality”, won’t be able to “Easily make DVDs”, and OMG, I won’t be able to “Have more fun on my PC”!!! That’s hilarious … you really have to read that! I loved the fact that it was blue, I like blue ..
Anyway, I installed it. Drivers thing works great, I didn’t need to update any driver except for the Realtek AC’97 Built-in Sound Card, which is cool - I was really happy not to do any extra driver updates for my ATI Radeon 9550 and to see my Network Adapter connecting peacefully to the Internet. I have installed some of the “usual” software as FireFox, NOD32, eMule, some codecs, VLC, WLMessenger, WLWriter, Paint.NET, etc. (will blog on that, too, soon). Everything seems fine so far, performance is great, and I didn’t need to reduce any effects to keep it up. I have an Intel Pentium 4 CPU 3.00 GHz and 1024 MB RAM - I was a little scared at first, especially for the RAMs, but no, thing are cool ..
I haven’t installed any of the huge software as Microsoft Visual Studio .NET 2008 or Adobe Photoshop CS3 and so on. We’ll see more when I get there .. If things work fine for a few more weeks, I’ll see about getting another one for my laptop ![]()

Exceptional Software, Explained: Embrace Error [OSCON2008]
August 10th, 2008 by Fouad Mohammedi have tried to follow the O’Reilly’s Open Source Convention (OSCON) for a bit .. but since i am not very familiar with most of the names .. i lost my interest later..
until i seen a video by GreggPollack titled Oscon in 37 minutes where every speaker summarizes his talk in 30 seconds..
i will try to cover the most interesting talks -for me- later .. but for now .. i will start with most i liked
it was by Robert ‘r0ml‘ Lefkowitz about Exceptional Software..Explained you can watch the 30 seconds from the previously mentioned video here
i will quote what he said
one of the things we are trying to do is encourage large enterprises to adopt the open source practices..
difficulty that .. although we have open source practices .. we don’t have open source methodology..
large companies are used to methodologies like Rational Unified Process or the Microsoft Solutions Framework or SCRUM or eXtreme Programming .. that define “how it is that you go about it”
and there is NO open source methodology for HOW YOU DEFINE SOFTWARE ?
and then you think that “MAN .. this is going to get very boring” .. but you must watch the 30 seconds and then you will get why it is not .. especially that he presents a totally new methodology other than what we are used to
i have dug for the complete talk .. and found it here
the talk is extremely fun .. and very insightful
you can download most of the presentations from here

Create you own polls, votes and surveys using Google Spreadsheets
August 8th, 2008 by Alaa Shaker
In many situations, a person needs to execute some survey, vote-collection or throwing a poll for instance. There are several online services that offer that at a low price. Since most of us prefer not paying, we either go to distributing documents through mass-mails then suffer collecting the results by hand, or simply let a user group do that service for you (as Yahoo! Groups - meaning that your audience should be member users), or use creepy pages with tons of ads to get it free.
Another solution would be using Google Spreadsheets from GoogleDocs.
This tutorial shows how you could easily use this solution to conclude polls, votes and surveys …
(If you prefer watching a video, click here)
- Go to GoogleDocs. Click New > Spreadsheet.
- I suggest the first thing you do, is save the Spreadsheet.
- From the tabs above, click Form. Then click Create a form.
- A new window will pop-up as shown below.
- Fill your form as follows:
- Enter a Title (default value to the name you saved the spreadsheet to).
- If you have any introduction text, enter that in the text area below the Title.
- For each question:
- Enter a Question Title.
- Use Help Text to provide hints or directions that help your audience answer your questions.
Example: If your asking about the name, you can type in the Help Text “Please, enter you full name.” If your asking for a phone number, you can type “Don’t forget your country code”. - Choose a Question Type:
- Text: Single-lined textual input, usually for names or short text answers.
- Paragraph Text: Same as text, but for longer answers (paragraphs), usually for comments, describe something, etc.
- Multiple Choice: Radio buttons that help you choose one of two or more options.
- Check Boxes: Helps you pick more than one answer from two or more options.
- Choose from a list: A drop-down list (combo box) to pick on of several items.
- Scale: Provide a scale the user ranging from 1 to n (where n lies between 3 and 10). You should provide two labels for the right- and left-most values (low and high).
- Check Mark this a required question if you want to.
- Click Done.
- You will see your question as it will appear on the form.
- Click Add a question to add more questions in the same manner.
You can also click Duplicate this question if you have a similar question and you don’t want to start the new one from scratch. (If it doesn’t show, hover over the old question in order to see it). - You can also reorder the questions by moving them up and down using the arrows that appear on the left when you hover over the question.
- After you are done, press Save. The press Preview and send.
- Copy the link marked above, and here you go!
Check the spreadsheet you saved earlier to see the collected results.
Now, you can easily (and for free) collect votes, polls and survey results as you please

tools i use..
August 6th, 2008 by Fouad Mohammedsince you might be digging the internet for a notepad replacement or an explorer extension that makes searching files easier..
i thought to save u some bandwidth .. and tell you about some tools i like
most of these are Free Software. برامج حرة
Exploring, Navigation and GUI
- Launchy

no need to Dig through Start>All Programs or fill the desktop with millions if files .. or look for Calc each time you need to add 55 + 78 …find your programs and run them in no time
- ClipX

use Ctrl+Shift+V .. to paste stuff that you copied and overwritten .. like office Clipboard but cooler - PowerMenu

if you like HackIt .. you will love PM, send any window to System Tray, makes it transparent or On Top - Rocket Dock
Coolest app from the Mac World - TeraCopy

Copy, Pause, Cancel and Resume in Windows Explorer and On Lan, hundreds of files. - StExBar

adds a Toolbar in your Explorer, with some handy stuff (open ComandLine here, copy all pathes, copy names, rename all) .. extremely useful. - GrepWin
if you are a Linux fan .. then u know grep .. and u also know that windows search is useless .. grepWin Lets you search inside files with a RegEx or for normal Text
AntiVirus
No matter what you do .. u can never rely on that.. so i will mention NONE
Network and Chat
- FireFox


u can see a cant be bias here - eMule

P2P file sharing program .. very configurable
Image via Wikipedia - Orbit / Free Download Manager
- CrossLoop
may be slower than LogMeIn.. lets you share the desktop with your friend.. very helpfull for remote assistance - Pidgin

aside the fact that current GTK+ release on windows is extremely buggy, Pidgin is All In One Chat Client, very light, very cool .. simply you can have 2 Gtalk accounts + 1 yahoo + 3 MSN in one window, one program - uTorrent


the smallest of all, compared to its feature richness.
Firefox Addons
- Firebug


helps you to analyze HTML, find problems with your website, debug javascript - FireFTP
.. obvious - Foxmarks


Sync your bookmarks across machines and even access them online

- FoxyProxy
Proxy management, go TOR or any other Proxy in seconds - QuickDrag


Drag and Drop any link in a new background tab .. instead of Ctrl+Click every time - Shareaholic
Found something awesome and cant wait to pass it on ? share over GReader, digg or anyother..
- SpeedDial
bookmarks in a smart way - Sxipper

Manages your passwords and fills-web forms .. extremely SMART
- TabMixPlus
want to make your tabs at the bottom of the page , control ordering , force 1 instance of FF ? - Zemanta
a blogger ? .. u MUST try this
General Purpose
- Foxit Reader
compared to Adobe reader ? .. this one should be rated (999/5) - WordWeb

aka Churchill, a compact Dictionary, with shourtcut keys , just select, press ALT+T and u see the meaning. the last version is wierd, but its free any way - Notepad++
take alook for yourself, it can replace Notpad interly by the way
Audio Vedio
- Winamp ..
- Audacity

A Free, Cross-Platform Digital Audio Editor under GPL - MediaCoder

Convert from any thing to any thing.. another verygood OSS
Burners, ZipFiles
- InfraRecorder

OpenSource Image Burner .. a free/Light Nero alternative and works great! - Daemon Tools
OpenSource, Simulates a CD from an image, much compact than PowerISO and VirtualCD
- 7-Zip

Tired of the “your evaluation Copy expired” every time you open a zip file in WinRAR ?, 7-zip is the OpenSource alternative
Now to the best part
Development Tools
- pInvoke VS addon

get the pinvok signature of any function from PInvoke.Net - VisualAssistX



Not Free, but simply addictive - ProcessExplorer
gives you every detail about any process in your system - DependencyWalker


Know what DLL’s your program loads.. know what symbols are exported by your DLL, TakeALook - TortoiseSVN


Source Control Management .. if you are still makeing copies of your code and sending them through mail in zip files to your friends .. then you should start using SVN - CMake
convert Makefiles into VS Solutions - WinMerge

merge two code files or folders, see what changed , bla bla .. the best windows diff tool
i think that’s all.. you want to share a tool you like ? .. place it in the comments

Saving a Bitmap
August 3rd, 2008 by Roaa Mohammed
Bitmap bmp = new Bitmap(@"C:\Pic.jpg");
..
//Do some Operations on bmp
..
btm.Save(@"C:\Pic.jpg");
An Exceptions is then fired on the bmp.Save(..) statement "A generic error occurred in GDI+"
At the first look, it seemed strange to see the exception esp the "Save" method should handle the overwriting process..
Yet, here was the mistake.. After creating the first bitmap from the image file, a lock has been done on the file in the memory, & then later, we are trying to save the bitmap in the same file (which is currently locked) & that's why we get that exception.
It will work in case you wanted to save in different paths, but not in case of overwriting..
so the suggested solutions was to create a copy from that bitmap, make the operations on that copy.. then dispose the bmp object (to release the lock) & later on save it (using the copy).. the new code should look as follows :
Bitmap bmp = new Bitmap(@"C:\Pic.jpg");
Bitmap copy = new Bitmap(bmp.Width, bmp.Height);
Graphics g = Graphics.FromImage(copy);
g.DrawImage(bmp, new Point(0, 0));
..
//Do some Operations on copy
..
//release the image file
bmp.Dispose();
bmp = copy;
bmp.Save(@"C:\Pic.jpg");
That's it..























