As part of Rich UX development, a Silverlight client application can also be used to upload multiple files from the client machine to the Web Server. Let us assume a business requirement as below:
The end-user is using a Silverlight application. He/she is writing application data in some files on the disk e.g. using a Rich UX Hospital Management System, the doctor creates a Case Paper for the patient along with ECG reports and blood sugar information. Now he wants to upload all these files at once to the Web Server, so that these reports can be accessed from any other location. Well in such cases, a Silverlight application with multiple file upload facility can definitely be helpful. In the code shown below, I have explained the mechanism of uploading multiple files using Silverlight 4.
Step 1: Open VS2010 and create a Silverlight Application, name it as ‘SL4_UploadingMultipleFiles_To_Server’. In the ASP.NET Host web Project i.e. ‘SL4_UploadingMultipleFiles_To_Server.Web’ project, add a Generic Handler and call it ‘UploadFileHandler.ashx’. This handler will contain code that accepts the file from the Silverlight application as a stream and writes on the disk in a specific folder. Also add a new folder in the Web project and call it ‘FilesServer’. This folder will be used to store uploaded files. The code is as shown below:
The method ProcessRequest accepts the input file to be written on the disk as a QueryString. The method shown above contains comments to help understand the code.
Step 2: Open MainPage.xaml and write the following Xaml code:
Read more: net curry