Almost every web site/portal has image upload facility on its forms i.e either its a social networking site or buy/sell site. Also their is one common need of image resize which play a vital role in look n feel of your displayed items, because e.g if a product site has 10 items on a single page but image size of each items is defferent then that look very bad and unprofessional. So i started to find so existing code/library and come across below given wonderful article by Faisal Khan.

Title: Uploading, Determining Size, Width and Height and Resizing Image Files with ASP.NET

Win Xp: Set Permissions On Files Or Folders

Posted by Zafar Ullah - zafarjcp@gmail.com | 12:49 PM | 0 comments »

Set permissions on files or folders (Windows XP, Windows 2000)

To set permissions on individual files and on folders, you must use NTFS file system.
NTFS file system provides features such as: Encrypt files, Compress a file or folder, Disk quotas and Set permissions on files or folders.
To convert a drive (for example drive C) to NTFS go to command prompt and type>> convert C: /fs:ntfs
Note that you cannot simply convert it back to FAT or FAT32.
OK, enough
1-By default, Windows does not display Security tab in files or folders Properties. To enable this feature go to Folder Options and clear “Use Simple File Sharing” check box in view tab.
2- Right click on your file or folder and click Properties, click Security tab and set permissions. For additional permissions or inheritance information click on Advanced.

Show files and folder not working on Win XP

Posted by Zafar Ullah - zafarjcp@gmail.com | 10:06 AM | 0 comments »

This Method is working perfectily

Go to the following registry key:
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Adva­nced\Folder\Hidden\SHOWALL

DELETE the value CheckedValue in the right window. (Its type should be REG_SZ and data should be 2.)

Now create a new DWORD value called CheckedValue (same as above, except that the type is REG_DWORD). Modify the value data to 1 (0x00000001).

This should let you change the "Hidden Files and Folders" option.

This exception comes when ever any of your objects property have some invalid value i.e value that is not according to provided mapping of that object. e.g while handling optimistic concurrency if you didnt add Unsaved-value="-1" in your versin property i.e



then it leads to hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
because the requirment of version field is "-1" when in default state.

NHibernate: SqlDateTime overflow Issue on object Update

Posted by Zafar Ullah - zafarjcp@gmail.com | 4:53 AM | , | 0 comments »

Yesterday i come across NHibernate SqlDateTime overflow exception when ever i update my object. During debug i all datetime fields have there default values/entered values but when i Flush my session it throws this noughty exception :)

Data.SqlTypes.SqlTypeException with the message "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.".

after alot of findings finally i found the reason behind this. Actually I didn't map that column as a Nullable OR DateTime? but just as DateTime. and when ever NHibernate read the row from DB its default value is null which NHibernate remembers. When the Object is rehydrated by NHibernate the Date is set to the value DateTime.MinValue. When the Session is synchronized with the db, NHibernate assumes that something has changed, because the currentState and the previousState are different and tries to update the row. Wich in turn fails, because DateTime.MinValue won't fit into a SqlServer datetime column.

The solution:
Make your datetime nullable either by putting ? at end of Datetime like DateTime? or Nullable<datetime>

e.g

[Property(Name = "CreatedDate", Column = "CreatedDate", NotNull = false)]//NotNull=false means null is allowed.
private DateTime? _createdDate = DateTime.Now;

I prefer using DateTime? rather then Nullable because that leades to change the date type where ever used.