Hello guys, i am a beginer in c#. if i type one letter in text box needs to get all the file names starts with that letter into text box in c# windows application . i want to get the all file names from the directory into the text box in win forms app.. I am giving you the code can u please correct it.please. i am giving the code can you please corret it it is very urgent to me please
[using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// Create the list to use as the custom source.
var source = new AutoCompleteStringCollection();
AddRange(DirectoryInfo File = @"D:\gopinath\DATES");
foreach (FileInfo fi in File.getfiles)
{
textBox = fi.Name.Tostring(); //it will show the name in the text box
};
//source.AddRange(Directory.GetFiles(@"D:\gopinath\D ATES", SearchOption.AllDirectories));
// source.AddRange(new string[]
// {
// "January",
// "February",
// "March",
// "April",
// "May",
// "June",
// "July",
// "August",
// "September",
// "October",
// "November",
// "December"
// });
// Create and initialize the text box.
var textBox = new TextBox
{
AutoCompleteCustomSource = source,
AutoCompleteMode=
AutoCompleteMode.SuggestAppend,
AutoCompleteSource =
AutoCompleteSource.CustomSource,
Location = new Point(20, 20),
Width = ClientRectangle.Width - 40,
Visible = true
};
// Add the text box to the form.
Controls.Add(textBox);
}
}
}
]