Gerben

Gerben

  • NA
  • 9
  • 0

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

Oct 30 2007 7:02 AM

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?

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()); }

}

 

 


Answers (2)