Display Record According to ComboBox Selection in CSharp .NET

Here I’m going to demonstrate how to delete all Temporary Internet Files of

Internet Explorer through C#.Net.

Example

private void btnDelete_Click(object sender, EventArgs e)
        {
//creating directory info and asigning it the path of internet cache.
DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
//assigning no. of directories in the folder to x
            int x = di.GetDirectories().Count();            
//calling clear() method
            clear(di);
            MessageBox.Show('Deleted');
        }
 
//clear() Method
        public void clear(DirectoryInfo di)
        {  
//loop for each file in directory           
            foreach (FileInfo fi in di.GetFiles())
            {
                try
                {
//deleting the file
                    fi.Delete();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }
//claaing clear() method recursively for each directory in current directory.
            foreach (DirectoryInfo sub in di.GetDirectories())
                clear(sub);
        }
 
 
Last updated:3/4/2020 3:48:15 AM
Anonymous User

Anonymous User

I am a content writter !

3 Comments

Shrikant Mishra
Shrikant Mishra

The ComboBox displays as a text box combined with a ListBox, which enables the user to select items from the list or enter a new value. Where the user can type a value in the text field or click the button to display a drop-down list. When You can add individual objects with the Add method.

Leave Comment