I want to upload a particular file on server in Silverlight 4,
Simply, to upload any file we can use the “Browse” button.
When you click on this button we can get the file directory and choose any file & we can upload the particular file.
i have coded on browse button
private void btnBrowse_Click(object sender, RoutedEventArgs e)
{
var fileDialog =new OpenFileDialog();
fileDialog.ShowDialog();
fileDialog.Multiselect = true;
txtUploader.Text = fileDialog.File.DirectoryName;
fileDialog.File.CopyTo("C:/UploadedFiles");
}
here the problem is, only the dialog box is opening
not able to select multiple file,
not getting path,
not able to upload the file to specified location.
Try changing the order that you are setting up your OpenFileDialog Box.
Also you are returning a FileInfo object. If you are going to return multiple files you need use Files instead of File it will return a collection of FileInfo objects. You can then iterate over the collection to get your information. In testing out the code I was getting a Security Exception on reading the path of the files, you do not have the permissions needed to do what you want to do per @MattGreer’s comment.
Edit added from @AnthonyWJones comment.
There is not any way to do what you are trying to do, except to create an OOB with elevated trust, and that will limit you to the users MyDocuments Folder.