here is a very good way to do it from the server.
( this is from dotnet2themax.com) and you could find all the code which could help you to create a class to be use in any project.
I tried to wrote you all the url but it seems that this is not allowed, but i encourage to visit this site.
http://www.dotnet2themax.com/<br /> ...6f-a6-e9-6f952

Hope this help, to me was very helpful