This project has moved and is read-only. For the latest updates, please go here.

Can Lite version be used as a single file selector

Jun 12, 2012 at 9:58 AM

I've been trying to get the lite version to work with selecting a single file but can't use the javascript 'FileAdded' event  to feedback useful information to the user when multiple files are selected as there is no count of how many files are to be added!

MaxUploads=1, is having no effect as far as I can see?

Is there a way to get the lite version to only allow selection of one file?

Coordinator
Jun 12, 2012 at 10:38 AM

There's no lite version of the single file uploader. The lite version is the same as the multiple file uploader, but without the interface.

It's not hard to create a lite version of the single file uploader, because they share the same core. But you'll have to do it yourself.

Probably the most easy thing to do is to modify the source of the lite version a little bit so that it can only select 1 file instead of multiple.

Go to this file:
mpost.SilverlightMultiFileUpload.Lite\MainPage.xaml

Remove this line (119):
ofd.Multiselect = true;

And recompile. Now you can only select 1 file.

 

Jun 12, 2012 at 4:42 PM

Thanks very much for this, I've done as you suggested and also amended the drag drop event to only read in the first file.

 private void LayoutRoot_Drop(object sender, DragEventArgs e) {

 

 FileInfo[] files = (FileInfo[])e.Data.GetData(System.Windows.DataFormats

.FileDrop);

 //This version is only used for a single file so this is removed...

 

 //foreach (FileInfo file in files)

 //{

 // AddFile(file);

 //}

 //This version is only used for a single file so only add the first file

AddFile(files[0]);

 

}

Works great using javascipt UI thanks very much - great app!