Kailash Sahu

Kailash Sahu

  • NA
  • 24
  • 570

I want to save full path of listbox in C#

Jul 22 2021 5:37 PM
First Of All I add Directory in Listbox, Like A Directory, B Directory. When User Click the item of ListBox ,Get the full path of Items in C# Someone modify the code ! Thanks in Advance ! BindingSource listboxsource = null; public Form1() { InitializeComponent(); listboxsource = new BindingSource(Properties.Settings.Default.listboxitems, ""); someListbox.DataSource = listboxsource; } //Add Folder in Listbox private void button57_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "Please Select Folder"; if (dialog.ShowDialog() == DialogResult.OK) { string folderName = dialog.SelectedPath; string s = Path.GetFileName(folderName); listboxsource.Add(s); Properties.Settings.Default.Save(); listboxsource = new BindingSource(Properties.Settings.Default.listboxitems, ""); someListbox.DataSource = listboxsource; } } private void listBox5_SelectedIndexChanged(object sender, EventArgs e) { try { string fullname = Properties.Settings.Default.FullName; Properties.Settings.Default.Save(); MessageBox.Show(fullname); } catch(Exception) { }

Answers (1)