Skip to content

How to determine whether a ListView item is a file or a folder?

Gerben

Asked Oct 30, 2007, 3:02 AM EDT2 answers
Share
LinkedInX

Hi,

I am building a form that should become custom directory browser.
How can I determine whether a selected ListView item is a file or a folder?

TypeScript
private void ProjectListView_ItemActivate(object sender, System.EventArgs e)
{
      try   {
               string sProjectsPath = (global::Offshore_Supports_Menu.Properties.Settings.Default.Projects_Dir);
               string sDir = ProjectTreeView.SelectedNode.FullPath;
               string sItem = ProjectListView.SelectedItems[0].Text;
               //If the sItem is a file then run the File
               Process.Start(sProjectsPath + "\\" + sDir + "\\" + sItem);
               //If the sItem is a folder then open the folder in ListView

               }
      catch (Exception Exc) { MessageBox.Show(Exc.ToString()); }
}

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Can you specify what what valus are there in the fullpath and the item text ?
    0
  • 0

    Thanx for your reaction ... but I solved the problem 30 minutes ago...

    0