using System; namespace Password_Manager { public class ResultListBox : ListBox { public ResultListBox() : base() { } public void Refresh() { DirectoryInfo d = new DirectoryInfo(Fields.CurrentProfile.Path); //Assuming Test is your Folder FileInfo[] files = d.GetFiles("*.gpg"); string[] elements = new string[files.Length]; for (int i = 0; i < elements.Length; i++) { elements[i] = files[i].Name; } this.DataSource = elements; } } }