Beispiel #1
0
        private void 属性RToolStripMenuItem1_MouseEnter(object sender, EventArgs e)
        {
            //要根据文件里面的type决定
            BasicFile clickedFile = getFileByItem(fileView.SelectedItems[0], fileView.View);

            toolStripComboBox1.Text = clickedFile.Type;
        }
        //更新父目录大小和磁盘占用情况
        public void updateCategory(BasicFile category, int[] fat)
        {
            int size = (category.ChildFile.Count() - 1) / 8 + 1;//实际大小

            delFat(category.StartNum, category.Size - size, fat);
            category.Size = size;
        }
        public void setDiskContent(String[] disk, BasicFile file, int[] fat)
        {
            int        j = 0;
            String     s = file.Content;
            List <int> arr;
            String     link;

            Console.WriteLine(file.StartNum);
            findFat(file.StartNum, out link, out arr, fat);

            for (int i = 0; i < file.Content.Length; i += 64)
            {
                if (i + 63 < file.Content.Length)
                {
                    disk[arr[j]] = s.Substring(i, 63);
                }
                else
                {
                    disk[arr[j]] = s.Substring(i, file.Content.Length - i);
                }
                j++;
                s = file.Content;
            }
            return;
        }
        private void label190_DoubleClick(object sender, EventArgs e)
        {
            Label  label = (Label)sender;
            string str   = toolTip1.GetToolTip(label);

            int startIndex = str.IndexOf('r');
            int endIndex   = str.IndexOf('|');

            if (startIndex == -1 || endIndex == -1)
            {
                return;
            }
            else
            {
                BasicFile        file = FileFunction.GetInstance().searchFile(str.Substring(startIndex, endIndex - startIndex), parentform.root);
                List <BasicFile> list = new List <BasicFile>();
                if (file.Attr == 2)
                {
                    MessageBox.Show(parentform.disk_Content[Convert.ToInt32(label.Text)], "磁盘块内容", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Dictionary<string, BasicFile> dic = new Dictionary<string, BasicFile>();
                    //dic.Add(file.Name, file);
                    //File_information of = new File_information(dic);
                    //SetParent((int)of.Handle, (int)this.parentform.Handle);
                    //of.Show();
                }
                else
                {
                    File_information of = new File_information(file.ChildFile, parentform.fat);
                    SetParent((int)of.Handle, (int)this.parentform.Handle);
                    of.Show();
                }
            }
            //MessageBox.Show();
        }
Beispiel #5
0
        //树形图的构建
        private void makeTreeViewWithFile(BasicFile file, TreeNode lastNode)
        {
            if (lastNode.Text == "root")
            {
                lastNode.ImageIndex         = 0;
                lastNode.SelectedImageIndex = 0;
                //lastNode.ContextMenuStrip = RightClick_View;
                treeView.Nodes.Add(lastNode);
            }

            foreach (var x in file.ChildFile)
            {
                BasicFile cFile = x.Value;
                if (cFile.Attr == 3)
                {
                    //是文件夹则创建节点
                    TreeNode node = new TreeNode(cFile.Name);
                    node.ImageIndex         = 0;
                    node.SelectedImageIndex = 0;
                    //lastNode.ContextMenuStrip = RightClick_View;
                    //添加到上一层
                    lastNode.Nodes.Add(node);
                    makeTreeViewWithFile(cFile, node);
                }
            }
            treeView.ExpandAll();
        }
Beispiel #6
0
        private void 重命名MToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BasicFile clickedFile = getFileByItem(fileView.SelectedItems[0], fileView.View);
            string    s           = Interaction.InputBox("请输入一个名称", "重命名", clickedFile.Name, -1, -1);

            if (s == "")
            {
                return;
            }
            var regex = new Regex(@"^[^\/\:\*\?\""\<\>\|\,]+$");
            var m     = regex.Match(s);

            if (!m.Success)
            {
                MessageBox.Show("请勿在文件名中包含\\ / : * ? \" < > |等字符,请重新输入有效文件名!");
                return;
            }
            bool flag = FileFun.reName(clickedFile, s, clickedFile.Father);

            if (!flag)
            {
                MessageBox.Show("重命名失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            upDateTreeView();
            fileView_Activated(this, e);
        }
 //打开文件夹时
 public Form openFile(BasicFile clickFile, ref BasicFile fatherFile, ListView fileView, int[] fat, Dictionary <string, BasicFile> fileDictionary, String[] disk)
 {
     if (clickFile.Attr == 2)
     {
         if (clickFile.IsOpening == true)
         {
             MessageBox.Show("不能重复打开文件!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(null);
         }
         //新建文本窗口
         TXTFrom txt = new TXTFrom(ref clickFile, ref fat, fileDictionary, disk);
         txt.Text = clickFile.Name;
         //设置为已打开状态
         return(txt);
     }
     else if (clickFile.Attr == 3)
     {
         //清空fileShow
         fileView.Items.Clear();
         //设置FileShow里的father
         fatherFile = clickFile;
         //显示子目录
         if (fatherFile.ChildFile.Count != 0)
         {
             foreach (var x in fatherFile.ChildFile)
             {
                 fileView.Items.Add(x.Value.Item);
             }
         }
         return(null);
     }
     return(null);
 }
Beispiel #8
0
 public FileShow(FileMangerSystem form)
 {
     InitializeComponent();
     parent = form;
     father = parent.root;
     upDateTreeView();
 }
Beispiel #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string fatherpath;

            father        = FileFun.backFile(father.Path, parent.root, out fatherpath);
            pathShow.Text = fatherpath;
            fileView_Activated(this, e);
        }
Beispiel #10
0
        private int countDisk(BasicFile file)
        {
            int SUM = file.Size;

            foreach (var a in file.ChildFile)
            {
                SUM += countDisk(a.Value);
            }
            return(SUM);
        }
Beispiel #11
0
        private void  制ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (fileView.SelectedItems.Count > 0)
            {
                copyFile_list = new BasicFile[fileView.SelectedItems.Count];

                for (int i = 0; i < fileView.SelectedItems.Count; i++)
                {
                    copyFile_list[i] = new BasicFile(getFileByItem(fileView.SelectedItems[i], fileView.View));
                }
            }
        }
Beispiel #12
0
        //点击就可以进入该文件夹
        private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            String   path = "";
            TreeNode node = e.Node;

            while (node.Text != "root")
            {
                path = node.Text + @"\" + path;
                node = node.Parent;
            }
            path = @"root:\" + path;
            //跳转
            BasicFile value = FileFun.searchFile(path, this.parent.root);

            if (value == null)
            {
                MessageBox.Show("非法路径", "非法!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else if (value.Attr == 3)//是目录
            {
                father = value;
            }
            fileView_Activated(this, e);

            if (e.Button == MouseButtons.Right)
            {
                treeView.SelectedNode = e.Node;
                RightClick_Tree.Show(treeView.PointToScreen(new Point(e.X, e.Y)));
                if (copyFile_list == null)
                {
                    for (int i = 0; i < RightClick_Tree.Items.Count; i++)
                    {
                        if (RightClick_Tree.Items[i].Text == "粘贴(&V)")
                        {
                            RightClick_Tree.Items[i].Enabled = false;
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < RightClick_Tree.Items.Count; i++)
                    {
                        if (RightClick_Tree.Items[i].Text == "粘贴(&V)")
                        {
                            RightClick_Tree.Items[i].Enabled = true;
                            break;
                        }
                    }
                }
            }
        }
        public BasicFile createFile_(BasicFile nowCatalog, int[] fat, String name = "新建文件1.txt", String type = "读写", int size = 1, string suffix = "txt", string content = "")
        {
            if (fat[0] >= size)
            {   //判断磁盘剩余空间是否足够建立文件
                //该目录下是否寻找同名目录或文件
                if (nowCatalog.ChildFile.ContainsKey(name))
                {  //判断该文件是否存在
                    BasicFile value = nowCatalog.ChildFile[name];
                    if (value.Attr == 3)
                    {   //若存在同名目录 继续创建文件
                        int startNum = setFat(size, fat);

                        if (startNum == -1)//没有空间分配了
                        {
                            return(null);
                        }
                        BasicFile file = new BasicFile(name, type, startNum, size, nowCatalog.Path, suffix);
                        //内容复制
                        file.Content = content;

                        file.Father = nowCatalog;             //纪录上一层目录
                        nowCatalog.ChildFile.Add(name, file); //在父目录添加该文件
                        return(file);
                    }
                    else if (value.Attr == 2)
                    { //若同名文件已存在,则换名字
                        String   name_ = name;
                        String[] s     = name_.Split('.');
                        name_ = s[0] + "-副本" + "." + s[1];
                        return(createFile_(nowCatalog, fat, name_, type, size, suffix, content));
                    }
                }
                else
                { //若无同名文件或文件夹,继续创建文件
                    int startNum = setFat(size, fat);

                    Console.WriteLine("startNum = " + startNum);

                    BasicFile file = new BasicFile(name, type, startNum, size, nowCatalog.Path, suffix);
                    //内容复制
                    file.Content = content;
                    file.Father  = nowCatalog;            //纪录上一层目录
                    nowCatalog.ChildFile.Add(name, file); //在父目录添加该文件
                    return(file);
                }
            }
            else
            {
                return(null);
            }
            return(null);
        }
        //复制的创建文件夹
        public BasicFile createCatolog_(BasicFile nowCatalog, int[] fat, BasicFile fatherFile, String name = "新建文件夹1")
        {
            //可以创建
            if (fat[0] >= 1)
            {
                //判断是否重命名
                if (nowCatalog.ChildFile.ContainsKey(name))
                {
                    BasicFile value = nowCatalog.ChildFile[name];
                    //不同类型,创建成功
                    if (value.Attr == 2)
                    {
                        int       startNum = this.setFat(1, fat);
                        BasicFile catalog  = new BasicFile(name, startNum, nowCatalog.Path);
                        //子文件夹复制
                        //catalog.ChildFile = fatherFile.ChildFile;
                        //设置父亲
                        catalog.Father = nowCatalog;
                        //添加到父文件夹下
                        nowCatalog.ChildFile.Add(catalog.Name, catalog);
                        return(catalog);
                    }
                    //相同类型,则帮改为默认命名
                    else if (value.Attr == 3)
                    {
                        Console.WriteLine("存在重复命名");
                        //以默认命名创建文件夹

                        return(createCatolog_(nowCatalog, fat, fatherFile, name + "-副本"));
                    }
                }
                //不存在同名的文件夹
                else
                {
                    int       startNum = this.setFat(1, fat);
                    BasicFile catalog  = new BasicFile(name, startNum, nowCatalog.Path);
                    //设置父亲
                    catalog.Father = nowCatalog;
                    //添加到父文件夹下
                    nowCatalog.ChildFile.Add(catalog.Name, catalog);
                    return(catalog);
                    // Console.WriteLine("文件夹创建成功");
                }
            }
            else
            {
                //以false为信号弹出失败窗口
                return(null);
            }
            return(null);
        }
Beispiel #15
0
        //属性更改时发现的事件
        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            BasicFile clickedFile = getFileByItem(fileView.SelectedItems[0], fileView.View);

            clickedFile.Type = toolStripComboBox1.Text;
            if (clickedFile.Type == "只读")
            {
                clickedFile.ReadOnly = true;
            }
            else
            {
                clickedFile.ReadOnly = false;
            }
        }
 /*
  *
  * 以下为返回上一层目录
  *
  */
 public BasicFile backFile(string path, BasicFile root, out string fpath)
 {
     if (path.Equals(@"root:"))
     {
         Console.WriteLine("已经是最上层目录");
         fpath = path;
         return(root);
     }
     else
     {
         BasicFile value      = searchFile(path, root);
         string    fatherpath = value.Father.Path;
         fpath = fatherpath;
         return(value.Father);
     }
 }
Beispiel #17
0
        private void  除DToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            String   path = "";
            TreeNode node = treeView.SelectedNode;

            if (node.Text == "root")
            {
                MessageBox.Show("根目录无法删除", "违规操作", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            while (node.Text != "root")
            {
                node = node.Parent;
                path = node.Text + @"\" + path;
            }
            path = path.Replace("root", @"root:");
            //跳转到父亲
            BasicFile value = FileFun.searchFile(path, this.parent.root);

            if (value == null)
            {
                MessageBox.Show("非法路径", "非法!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            else if (value.Attr == 3)//是目录
            {
                father = value;
            }

            //到时候还要获得名字
            BasicFile clickedFile = getFileByName(treeView.SelectedNode.Text);
            bool      flag        = FileFun.deleteFile(clickedFile, clickedFile.Father, this.parent.Fat, this.parent.disk_Content);

            if (!flag)
            {
                MessageBox.Show("删除文件失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                this.parent.OpenedFileList.Remove(clickedFile.Path);
                //树形视图的维护
                upDateTreeView();
            }
            fileView_Activated(this, e);
        }
 public void searchFile(BasicFile curFile, string name, ref List <BasicFile> fileArray)
 {
     if (curFile.Name.IndexOf(name) != -1 && !curFile.Name.Equals("root"))//要搜索的名字是该文件名的字串
     {
         fileArray.Add(curFile);
     }
     if (curFile.ChildFile.Count != 0)
     {
         foreach (var x in curFile.ChildFile)
         {
             searchFile(x.Value, name, ref fileArray);
         }
     }
     else
     {
         return;
     }
 }
Beispiel #19
0
        //点击新建文件
        private void 文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (father.ChildFile.Count >= father.Size * 8)
            {
                FileFun.reAddFat(father, 1, parent.fat);//追加目录磁盘块
            }
            BasicFile file = FileFunction.GetInstance().createFile(father, parent.Fat);

            if (file != null)
            {
                fileView.Items.Add(file.Item);
                fileView_Activated(this, e);
            }
            else
            {
                MessageBox.Show("创建文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        /*
         * 以下根据绝对路径寻找文件或目录
         * @return 返回目录或者文件。如果返回的是文件,则要打开不用跳转到父目录,如果返回的是目录,则要跳转到该目录
         */
        public BasicFile searchFile(string path, BasicFile root)
        {
            if (path[path.Length - 1].Equals('\\'))
            {
                path = path.Remove(path.Length - 1);
            }
            if (path.Length == 0)
            {
                return(null);
            }
            else
            {
                string[] name = path.Split(@"\"[0]);

                if (name[0].Equals(@"root:"))
                {
                    if (name.Length == 1)//只是根目录
                    {
                        return(root);
                    }
                    else//有多级目录
                    {
                        BasicFile tmpCatalog = root;
                        for (int i = 1; i < name.Length; i++)
                        {
                            if (tmpCatalog.ChildFile.ContainsKey(name[i]))//判断该文件是否存在
                            {
                                tmpCatalog = tmpCatalog.ChildFile[name[i]];
                            }
                            else
                            {
                                return(null);//非法路径
                            }
                        }
                        return(tmpCatalog);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
        /*
         * 以下根据相对路径寻找文件或目录
         * @return 返回目录或者文件。如果返回的是文件,则要打开不用跳转到父目录,如果返回的是目录,则要跳转到该目录
         */
        public BasicFile searchFile(string path, BasicFile root, BasicFile father)
        {
            string[]  name      = path.Split(@"\"[0]);
            BasicFile curFather = father;
            string    tmp       = "";

            foreach (var x in name)
            {
                if (x.Equals(@".."))
                {
                    curFather = curFather.Father;
                }
                else
                {
                    tmp += @"\" + x;
                }
            }
            Console.WriteLine(curFather.Path + tmp + "-------------");
            return(searchFile(curFather.Path + tmp, root));
        }
Beispiel #22
0
        //点击删除文件
        private void  除DToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //到时候还要获得名字
            for (int i = 0; i < fileView.SelectedItems.Count; i++)
            {
                BasicFile clickedFile = getFileByItem(fileView.SelectedItems[i], fileView.View);
                bool      flag        = FileFun.deleteFile(clickedFile, clickedFile.Father, this.parent.Fat, this.parent.disk_Content);
                if (!flag)
                {
                    MessageBox.Show("删除文件失败", "失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    this.parent.OpenedFileList.Remove(clickedFile.Path);
                    //树形视图的维护
                    upDateTreeView();
                }
            }

            fileView_Activated(this, e);
        }
Beispiel #23
0
        //点击新建文件夹
        private void 文件夹ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (father.ChildFile.Count >= father.Size * 8)
            {
                FileFun.reAddFat(father, 1, parent.fat);//追加目录磁盘块
            }
            BasicFile file = FileFun.createCatolog(father, parent.fat);

            //Console.WriteLine(father.getName());
            if (file != null)
            {
                fileView.Items.Add(file.Item);
                //树形视图的维护
                upDateTreeView();
                fileView_Activated(this, e);
            }
            else
            {
                MessageBox.Show("创建文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #24
0
        private void 详细信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BasicFile clickedFile = getFileByItem(fileView.SelectedItems[0], fileView.View);

            if (clickedFile.Attr == 2)
            {
                Dictionary <string, BasicFile> list = new Dictionary <string, BasicFile>();
                list.Add(clickedFile.Name, clickedFile);
                File_information of = new File_information(list, parent.fat);
                of.Text = "详细信息";
                SetParent((int)of.Handle, (int)this.parent.Handle);
                of.Show();
            }
            else
            {
                File_information of = new File_information(clickedFile.ChildFile, parent.fat);
                SetParent((int)of.Handle, (int)this.parent.Handle);
                of.Text = "详细信息";
                of.Show();
            }
        }
 /*
  *   以下为根据当前目录创建文件或者目录的方法
  *   参数为 文件名 文件类型 文件大小 当前目录 文件对象字典  FAT登记表
  */
 public BasicFile createFile(BasicFile nowCatalog, int[] fat, String name = "新建文件1.txt", int dept = 1, String type = "读写", int size = 1, string suffix = "txt")
 {
     if (fat[0] >= size)
     {   //判断磁盘剩余空间是否足够建立文件
         //该目录下是否寻找同名目录或文件
         if (nowCatalog.ChildFile.ContainsKey(name))
         {  //判断该文件是否存在
             BasicFile value = nowCatalog.ChildFile[name];
             if (value.Attr == 3)
             {                       //若存在同名目录 继续创建文件
                 int startNum = setFat(size, fat);
                 if (startNum == -1) //没有空间分配了
                 {
                     return(null);
                 }
                 BasicFile file = new BasicFile(name, type, startNum, size, nowCatalog.Path, suffix);
                 file.Father = nowCatalog;             //纪录上一层目录
                 nowCatalog.ChildFile.Add(name, file); //在父目录添加该文件
                 return(file);
             }
             else if (value.Attr == 2)
             { //若同名文件已存在,则换名字
                 return(createFile(nowCatalog, fat, "新建文件" + (dept + 1) + ".txt", dept + 1));
             }
         }
         else
         { //若无同名文件或文件夹,继续创建文件
             int       startNum = setFat(size, fat);
             BasicFile file     = new BasicFile(name, type, startNum, size, nowCatalog.Path, suffix);
             file.Father = nowCatalog;             //纪录上一层目录
             nowCatalog.ChildFile.Add(name, file); //在父目录添加该文件
             return(file);
         }
     }
     else
     {
         return(null);
     }
     return(null);
 }
Beispiel #26
0
        //递归复制
        private void copyCatolog(BasicFile copy_file, BasicFile file_father)
        {
            if (copy_file.Attr == 2)
            {
                //分配空间
                if (file_father.ChildFile.Count >= file_father.Size * 8)
                {
                    FileFun.reAddFat(file_father, 1, parent.fat);//追加目录磁盘块
                }
                BasicFile file = FileFunction.GetInstance().createFile_(file_father, parent.Fat, copy_file.Name, copy_file.Type, copy_file.Size, copy_file.Suffix, copy_file.Content);
                //创建成功
                if (file != null)
                {
                    FileFun.setDiskContent(parent.disk_Content, file, parent.fat);
                }
                else
                {
                    MessageBox.Show("复制文件失败", "磁盘空间不足!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            //文件夹
            else if (copy_file.Attr == 3)
            {
                if (file_father.ChildFile.Count >= file_father.Size * 8)
                {
                    FileFun.reAddFat(file_father, 1, parent.fat);//追加目录磁盘块
                }
                //创建1层文件夹
                BasicFile file = FileFun.createCatolog_(file_father, parent.fat, file_father, copy_file.Name);

                if (file != null)
                {
                    foreach (var a in copy_file.ChildFile)
                    {
                        //递归创建文件
                        copyCatolog(a.Value, file);
                    }
                }
            }
        }
        /*
         *
         * 以下为文件或文件夹重命名方法
         *
         */

        public bool reName(BasicFile File, String newName, BasicFile fatherFile)
        {
            if (newName.Equals(File.Name))//和本身名字一样
            {
                return(true);
            }
            if (fatherFile.ChildFile.ContainsKey(newName))
            {
                BasicFile file = null;
                fatherFile.ChildFile.TryGetValue(newName, out file);
                if (file.Attr == File.Attr)//存在同名
                {
                    return(false);
                }
                else//存在同名,但不是同一类型文件
                {
                    fatherFile.ChildFile.Remove(File.Name);
                    fatherFile.ChildFile.Add(newName, File);
                    File.Name = newName;
                    if (File.Attr == 2)//如果是文件,则提取后缀名
                    {
                        string[] str = newName.Split('.');
                        File.Suffix = str[str.Length - 1];
                    }
                    return(true);
                }
            }
            else
            {
                fatherFile.ChildFile.Remove(File.Name);
                fatherFile.ChildFile.Add(newName, File);
                File.Name = newName;
                if (File.Attr == 2)//如果是文件,则提取后缀名
                {
                    string[] str = newName.Split('.');
                    File.Suffix = str[str.Length - 1];
                }
                return(true);
            }
        }
Beispiel #28
0
        private void pathShow_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                BasicFile value = null;
                if (!pathShow.Text.StartsWith("root:"))//相对路径
                {
                    //MessageBox.Show(father.Name);
                    value = FileFun.searchFile(pathShow.Text, parent.root, father);
                }
                else//绝对路径
                {
                    value = FileFun.searchFile(pathShow.Text, parent.root);
                }
                if (value == null)
                {
                    MessageBox.Show("非法路径", "非法!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (value.Attr == 2)//是文件则打开,不跳转
                    {
                        Form form = FileFun.openFile(value, ref father, fileView, parent.fat, parent.openedFileList, parent.disk_Content);
                        if (form != null)
                        {
                            SetParent((int)form.Handle, (int)this.parent.Handle);

                            form.Show();
                            this.parent.OpenedFileList.Add(value.Path, value);
                        }
                    }
                    else if (value.Attr == 3)//是目录
                    {
                        father = value;
                    }
                    fileView_Activated(this, e);
                }
            }
        }
 public void changeType(String name, String type, BasicFile fatherFile)
 {
     if (fatherFile.ChildFile.ContainsKey(name))
     {
         BasicFile file;
         fatherFile.ChildFile.TryGetValue(name, out file);
         if (file.Type == type)
         {
             Console.WriteLine("改类型失败,相同的类型");
         }
         else
         {
             file.Type = type;
             fatherFile.ChildFile.Remove(name);
             fatherFile.ChildFile.Add(name, file);
             Console.WriteLine("更改类型成功!");
         }
     }
     else
     {
         Console.WriteLine("改类型失败,没有该文件!");
     }
 }
Beispiel #30
0
        //双击事件
        private void 打开OToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //得到改文件夹,以及该文件夹的父亲
            BasicFile clickedFile = getFileByItem(fileView.SelectedItems[0], fileView.View);
            Form      FileFrom    = FileFun.openFile(clickedFile, ref father, fileView, parent.fat, parent.openedFileList, parent.disk_Content);

            if (FileFrom != null)
            {
                TXTFrom FileFrom1 = (TXTFrom)FileFrom;

                SetParent((int)FileFrom1.Handle, (int)this.parent.Handle);

                FileFrom1.Show();
                if (clickedFile.Attr == 2)
                {
                    this.parent.OpenedFileList.Add(clickedFile.Path, clickedFile);
                }
            }
            if (clickedFile.Attr == 3)
            {
                pathShow.Text += @"\" + clickedFile.Name;
                fileView_Activated(this, e);
            }
        }