Reputation: 1324
In my silverlight application I would like to be able to select a file from an OpenFileDialog window and upload/copy it to a local folder in my Silverlight project. I am already able to setup a OpenFileDialog window and set some options to it, but unfortunately I can't find a way to create a filestream and then copy it to a local folder.
private void Change_Avatar_Button_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog();
openfile.Multiselect = false;
openfile.Filter = "Images files (*.bmp, *.png)|*.bmp;*.png";
if ((bool)openfile.ShowDialog())
{
}
}
I've tried looking at many tutorials on the net, but they only seem to send the file directly to the UploadFile method in silverlight what I do not want to do at the moment.
Thank you, Ephismen.
Upvotes: 0
Views: 4130
Reputation: 93601
You can't just write files to local folders without prompting the user a second time (e.g. save as dialog http://www.silverlightshow.net/items/Using-the-SaveFileDialog-in-Silverlight-3.aspx)
You could write it to isolated storage instead: http://blogs.silverlight.net/blogs/msnow/archive/2009/05/21/71909.aspx.
If you want specific examples (e.g. going straight from OpenFileDialog to Isolated storage) I strongly recommend you use Google. The first match on "silverlight openfiledialog to isolated storage" is this: http://forums.silverlight.net/forums/t/201362.aspx
Upvotes: 1