public List <Item> GetItemsInternal(string path)
        {
            var items = new List <Item>();

            var dirInfo = new DirectoryInfo(path);

            foreach (var directory in dirInfo.GetDirectories())
            {
                var item = new DirectoryItem
                {
                    Name  = directory.Name,
                    Path  = directory.FullName,
                    Items = GetItemsInternal(directory.FullName)
                };

                items.Add(item);
            }

            foreach (var file in dirInfo.GetFiles())
            {
                var item = new FileItem
                {
                    Name = file.Name,
                    Path = file.FullName
                };

                if (file.Extension == ".cs")
                {
                    items.Add(item);
                }
            }

            return(items);
        }
        public List <Item> GetItems(string path, out string csProjPath)
        {
            csProjPath = "";
            string      str   = "";
            var         items = new List <Item>();
            List <Item> ret   = new List <Item>();

            var  dirInfo  = new DirectoryInfo(path);
            bool isCsProj = false;

            foreach (var file in dirInfo.GetFiles())
            {
                var item = new FileItem
                {
                    Name = file.Name,
                    Path = file.FullName
                };

                if (file.Extension == ".cs")
                {
                    items.Add(item);
                }

                if (file.Extension == ".csproj")
                {
                    isCsProj   = true;
                    csProjPath = file.FullName;
                    str        = file.Name;
                }
            }

            if (!isCsProj)
            {
                MessageBox.Show("There's no .csproj file in main folder");
                return(null);
            }

            foreach (var directory in dirInfo.GetDirectories())
            {
                var item = new DirectoryItem
                {
                    Name  = directory.Name,
                    Path  = directory.FullName,
                    Items = GetItemsInternal(directory.FullName)
                };

                items.Add(item);
            }

            List <Item> p = new List <Item>();

            p.Add(new DirectoryItem("Project: " + System.IO.Path.GetFileNameWithoutExtension(str), csProjPath, items));
            return(p);
        }
        private void fileTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (fileTree.SelectedItem is DirectoryItem)
            {
                DirectoryItem it    = (DirectoryItem)fileTree.SelectedItem;
                var           split = it.Name.Split(':');

                if (split.Length > 1 && split[0] == "Project")
                {
                    ProjectPath = it.ProjPath;
                }
            }
        }