Beispiel #1
0
        /// <summary>
        /// Load all sub-folders into the Folders collection of the
        /// given <paramref name="parentItem"/>.
        /// </summary>
        /// <param name="parentItem"></param>
        internal static void LoadFolders(ITreeItemViewModel parentItem)
        {
            try
            {
                parentItem.ChildrenClear();

                foreach (string dir in Directory.GetDirectories(parentItem.ItemPath))
                {
                    try
                    {
                        FolderViewModel.AddFolder(dir, parentItem);
                    }
                    catch (UnauthorizedAccessException ae)
                    {
                        parentItem.ShowNotification(FileSystemModels.Local.Strings.STR_MSG_UnknownError, ae.Message);
                    }
                    catch (IOException ie)
                    {
                        parentItem.ShowNotification(FileSystemModels.Local.Strings.STR_MSG_UnknownError, ie.Message);
                    }
                }
            }
            catch (UnauthorizedAccessException ae)
            {
                parentItem.ShowNotification(FileSystemModels.Local.Strings.STR_MSG_UnknownError, ae.Message);
            }
            catch (IOException ie)
            {
                parentItem.ShowNotification(FileSystemModels.Local.Strings.STR_MSG_UnknownError, ie.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Add a new folder indicated by <paramref name="dir"/> as path
        /// into the sub-folder viewmodel collection of this folder item.
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="parentItem"></param>
        /// <returns></returns>
        internal static TreeItemViewModel AddFolder(string dir,
                                                    ITreeItemViewModel parentItem)
        {
            try
            {
                DirectoryInfo di = new DirectoryInfo(dir);

                // create the sub-structure only if this is not a hidden directory
                //                if ((di.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                //                {
                var newFolder = new FolderViewModel(dir, parentItem);

                parentItem.ChildAdd(newFolder);

                return(newFolder);
                //                }
            }
            catch (UnauthorizedAccessException ae)
            {
                parentItem.ShowNotification(FileSystemModels.Local.Strings.STR_MSG_UnknownError, ae.Message);
            }
            catch (Exception e)
            {
                parentItem.ShowNotification(FileSystemModels.Local.Strings.STR_MSG_UnknownError, e.Message);
            }

            return(null);
        }