Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- put into listbox
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (listBox1.SelectedItem == null)
- {
- MessageBox.Show("Please select a tab in the listbox.", "Error.", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- textBox1.Text = File.ReadAllText($"./Scripts/{listBox1.SelectedItem}");
- }
- -- refresh code
- listBox1.Items.Clear();//Clear Items in the ListBox
- Functions.PopulateListBox(listBox1, "./Scripts", "*.txt");
- Functions.PopulateListBox(listBox1, "./Scripts", "*.lua");
- -- put into functions
- public static void PopulateListBox(ListBox lsb, string Folder, string FileType)
- {
- DirectoryInfo dinfo = new DirectoryInfo(Folder);
- FileInfo[] Files = dinfo.GetFiles(FileType);
- foreach (FileInfo file in Files)
- {
- lsb.Items.Add(file.Name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement