Home > View Post

Updated Silverlight Uploader for SL2 Beta 2

UPDATE: Get the RTW version here: Silverlight 2 File Uploader: Final!

In late May I updated my original Silverlight file uploader with a new one for Silverlight 2 Beta 1. Well, Beta 2 has been out for a little while now so we're about due for another update.

The changes required were fairly minimal:

  • The OpenFileDialog's ShowDialog method now returns bool? which is more consistent with WPF (as opposed to using the DialogResult enum).
  • The OpenFileDialog now has a MultiSelect property instead of an EnableMultiSelect property.
  • You can no longer ResourceDictionary Add method now requires a key, where the previous version didn't.
Job done.

Once again you can play with a demo version of the control here:

Note, this doesn't actually upload the files - it just pretends too and pretends every third file already exists on the server :)


Source Code

As usual, this is SAMPLE CODE and has not been optimised. It has been written in a short time for a personal project and as such hasn't been subject to a great deal of testing. The content is provided "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Tags: Silverlight

Josh Post By Josh Twist
2:36 AM
30 Jun 2008

» Next Post: A Silverlight 2 Databinding Cornucopia
« Previous Post: Creating AD user accounts in PowerShell

Comments are closed for this post.

Posted by Voytek @ 28 Jul 2008 7:42 AM
This is excellent piece of code. I finally understand how to keep the track of the uploaded files. Currently I am using code based on “Uploading with Silverlight 2 Beta 1 and WCF” http://michaelsync.net/2008/03/27/uploading-with-silveright-2-beta-1-and-wcf. This is another quality sample. Works like a charm but uploads only one file at the time. I’ve modified it to process multiple files but couldn’t find the foolproof method of checking the progress and status of the downloaded file. Your code gave me some new ideas and I want to combine these two concepts into one. No luck so far, I am stack at the very end when I try to call the web service.
I’ll keep checking this website for any future updates. Keep them coming please. Currently this is the only site on the web where one can learn how to build multiple files uploader in Silverlight 2. I’m really surprised that this type of tutorial is not posted on the main Silverlight site.

Posted by ankit @ 08 Sep 2008 7:03 PM
It's really good example.

However, It's not showing what time left for upload. It's just progress.

Posted by Josh @ 08 Sep 2008 11:43 PM
Because we don't really know. You could estimate it after the first file completes but that was why I provided the source :)

Posted by tw3 @ 18 Sep 2008 6:59 AM
Nice Sample. Could you post the code for the web service?

Posted by Josh @ 18 Sep 2008 11:43 PM
It's listed on the original post at http://www.thejoyofcode.com/Updated_Silverlight_Uploader_for_SL2_Beta_1.aspx - it's literally tiny so a cut and paste should cover you.


Posted by Dirk @ 24 Sep 2008 12:37 AM
Hello Josh,

I'm a newbie in C# and Silverlight. Your Uploadler is a nice stuff of code. But I try four days to sent a additional path from the silverlight client to the webservice. I generate a GUID at startup the silverlight application. On the server I'll create a new directory with the GUID as name for example. Anything i try is fault.
First I try add the following code to the webservice:
public string _myPath = "";
public void getPath(string customerPath)
_myPath = _uploadPath + "/" + customerPath;

But the Method will not shown in the UploadService.cs, Uploader.cs and so on.

On a second way I try to use WCF. Here I can Upload, send and create the path. But here it isn't possible for me to convert your statusbar from asmx to wcf.

Can you help me? What I've to do, when I'll send a additional path-Parameter to the webservice?

Best Regards

© 2005 - 2022 Josh Twist - All Rights Reserved.