Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Контрольная работа по "Программированию"

Автор:   •  Июнь 4, 2020  •  Контрольная работа  •  1,364 Слов (6 Страниц)  •  218 Просмотры

Страница 1 из 6

Код программы

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.IO;

using System.Diagnostics;

namespace WindowsFormsApp3

{

    public partial class FormTree : Form

    {

// выводит сведений обо всех дисках в текущей системе.

        DriveInfo[] dr = DriveInfo.GetDrives();

        public FormTree()

        {

            InitializeComponent();

        }

//получение файлов и папок с компьютера

        void buildDirr(TreeNode _tn_selected_node)

        {

            try

            {

                if (_tn_selected_node.FirstNode == null || _tn_selected_node.FirstNode.Text == "")

                {

                    if (_tn_selected_node.FirstNode != null)

                    {

                        _tn_selected_node.FirstNode.Remove();

                    }

                    DirectoryInfo _root_dir = new DirectoryInfo(getFullDirr(_tn_selected_node));

                    foreach (DirectoryInfo _child_directory in _root_dir.GetDirectories())

                    {

                        _tn_selected_node.Nodes.Add(_child_directory.Name);

                        _tn_selected_node.LastNode.ContextMenuStrip = contextMenuStrip2;

                        _tn_selected_node.LastNode.Nodes.Add("");

                    }

                    foreach (FileInfo _child_file in _root_dir.GetFiles())

                    {

                        _tn_selected_node.Nodes.Add(_child_file.Name);

                        _tn_selected_node.LastNode.ContextMenuStrip = contextMenuStrip1;

                    }

                    _tn_selected_node.Expand();

                }

            }

            catch (System.Exception excpt)

            {

                Console.WriteLine(excpt.Message);

            }

        }

        String getFullDirr(TreeNode _tn_node)

        {

            String _s_full_dir = _tn_node.Text;

            if (_tn_node.Parent != null)

            {

                _s_full_dir = getFullDirr(_tn_node.Parent) + "\\" + _s_full_dir;

            }

            if (_s_full_dir.Contains("\\\\"))

...

Скачать:   txt (4.6 Kb)   pdf (72.8 Kb)   docx (10.5 Kb)  
Продолжить читать еще 5 страниц(ы) »
Доступно только на Essays.club