How to upload multiple files in wpf using web client class

Sep 17 2018 7:35 AM
Hi I want to upload multiple files in wpf using web client class....
 
this is my xaml design and code
 
private void btnOpenFiles_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Multiselect = true;
openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (openFileDialog.ShowDialog() == true)
{
foreach (string filename in openFileDialog.FileNames)
lbFiles.Items.Add(System.IO.Path.GetFileName(filename));
}
}
 
this is xaml design
 
<DockPanel Margin="10">
<WrapPanel HorizontalAlignment="Center" DockPanel.Dock="Top" Margin="0,0,0,10">
<Button Height="60" Width="50" Name="btnOpenFile" Click="btnOpenFiles_Click">Open files</Button>
</WrapPanel>
<ListBox Name="lbFiles" Height="80" />
<Button Height="50" Width="80" Name="btnUploadFile" Click="btnUploadFiles_Click">Upload files</Button>
</DockPanel>
 
am able to select multiple files...again how to send all the selected files to the server .
Thanks in Advance

Answers (2)