It clears browserListView and adds the element Go Up One Level

It clears browserlistview and adds the element go up

This preview shows page 19 - 25 out of 32 pages.

It clears browserListView and adds the element "Go Up One Level". browserListView.Items.Clear(); browserListView.Items.Add("Go Up One Level"); When the user clicks this element, the program attempts to move up one level.
Image of page 19
Method LoadFilesInDirectory The method then creates a DirectoryInfo object initialized with the string currentDirectory . currentDirectory = currentDirectoryValue; DirectoryInfo newCurrentDirectory = new DirectoryInfo(currentDirectory); Class DirectoryInfo (namespace System.IO) enables us to browse or manipulate the directory structure easily.
Image of page 20
Method LoadFilesInDirectory Method GetDirectories returns an array of DirectoryInfo objects containing the subdirectories of the current directory. DirectoryInfo[] directoryArray = new CurrentDirectory.GetDirectories(); Similarly, method GetFiles returns an array of class FileInfo objects containing the files in the current directory. FileInfo[] fileArray = new CurrentDirectory.GetFiles(); Property Name (of both class DirectoryInfo and class FileInfo) contains only the directory or file name, such as temp instead of C:\myfolder\temp. To access the full name, use property FullName .
Image of page 21
Method LoadFilesInDirectory foreach (DirectoryInfo dir in directoryArray) { ListViewItem newDirectoryItem = browserListView.Items.Add(dir.Name); newDirectoryItem.ImageIndex = 0; // set directory image } foreach (FileInfo file in fileArray) { ListViewItem newFileItem = browserListView.Items.Add(file.Name); newFileItem.ImageIndex = 1; // set file image }
Image of page 22
Method browserListView_Click Method browserListView_Click responds when the user clicks control browserListView . It first checks whether anything is selected. if (browserListView.SelectedItems.Count != 0) If a selection has been made, line 29 determines whether the user chose the first item in browserListView. The first item in browserListView is always Go Up One Level; if (browserListView.Items[0].Selected)
Image of page 23
Method browserListView_Click Program creates a DirectoryInfo object for the current directory. DirectoryInfo directoryObject = new DirectoryInfo(currentDirectory); If a parent directory does exist, pass the parent directory’s full name to LoadFilesInDirectory .
Image of page 24
Image of page 25

You've reached the end of your free preview.

Want to read all 32 pages?

  • Fall '18
  • Zia Ul Rehman
  • home directory, root directory, Click, Working directory, TabPage

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes