I am displaying multiple images in listview from database and is working fine, the problem am having is when ever I wan't to download multiple selected images into any folder on my desktop computer, only one image is downloaded not multiple selected images : check my codes
- FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
-
- if (folderBrowserDialog.ShowDialog() == DialogResult.OK) {
- if (listView1.Items.Count > 0) {
- listView1.FocusedItem = listView1.Items[0];
- listView1.Items[0].Selected = true;
- listView1.Select();
- SqlCommand cmd = new SqlCommand("SELECT Name,Data FROM [gallery]", connect);
- cmd.CommandType = CommandType.Text;
- connect.Open();
- SqlDataReader sdr = cmd.ExecuteReader();
- if (sdr.Read()) {
- byte[] bytes = (byte[]) sdr["Data"];
- string fileName = sdr["Name"].ToString();
- string path = Path.Combine(folderBrowserDialog.SelectedPath, fileName);
- File.WriteAllBytes(path, bytes);
- }
- connect.Close();
- }
- }