Home

Saturday, April 17, 2010

Creating zip file using winrar in C#.NET


There are times when we need to transfer large folders over the network. The best solution to optimize this transfer is to use a zip file. We can create a zip file in C#.NET by taking advantage of the zipping tool installed on the machine. Various zipping tools can be used for the purpose of zipping like winzip(undoubtedly the most famous one), winrar, 7-zip etc. Here I will make use of winrar for zipping a folder.

Friday, April 16, 2010

IsolatedStorageFile in Silverlight


Recently I was stuck over a problem of writing on the user's permanent storage using a silverlight application. With microsoft trying to give more security to the user by not allowing the silverlight application to write to a location of developers choice, surely the developers are left struggling with their desire to access the users hard-drive.

Silverlight has restricted the use of the most famous techniques of writing a file to the client's machine : namely Filestream and Streamwriter. On the contrary it has provided the developers with an alternative called IsolatedStorageFile. This class is part of the System.IO package.

Isolated storage reserves a location on the user's machine that microsoft considers to be safe. It resides in the Documents and settings folder of your OS partition. Initially a size of 1 mb is provided where data can be written. This size can be increased by using the IsolatedStorage.IncreaseQuotaTo(int noOfBytes). But one should remember that this statement will request the user to grant permission for the same. This has been done to provide increased security to the user. I would prefer that you use this location whenever you want to store less data like the passwords, user data etc. Here's an example to create an isolatedstorage to write a file in it.