Esempio n. 1
0
        private void 新建文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FileSystemTV.SelectedNode == null)
            {
                MessageBox.Show("没有选中文件夹!");
                return;
            }
            InputNameForm NewForm = new InputNameForm();

            if (NewForm.ShowDialog() == DialogResult.OK)
            {
                string CreateFilePath = FileSystemTV.SelectedNode.FullPath + '\\' + NewForm.FileName;
                try
                {
                    FileManagerInstance.CreateFile(CreateFilePath, false, DiskInode.FileType.Data);
                    ListFile(FileSystemTV.SelectedNode); //创建完成,刷新目录
                }
                catch (ArgumentException ex)
                {
                    if (ex.Message == "文件名重复!")
                    {
                        if (MessageBox.Show("发现已有同名文件,是否覆盖?", "是否覆盖", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            try
                            {
                                FileManagerInstance.CreateFile(CreateFilePath, true, DiskInode.FileType.Data);
                            }
                            catch (Exception _ex)
                            {
                                MessageBox.Show(_ex.Message);
                            }
                            ListFile(FileSystemTV.SelectedNode); //创建完成,刷新目录
                        }
                    }
                    else
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            CheckSpaceUsage();
        }
Esempio n. 2
0
        private void 新建文件夹ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FileSystemTV.SelectedNode == null)
            {
                MessageBox.Show("没有选中文件夹!");
                return;
            }
            InputNameForm NewForm = new InputNameForm();

            if (NewForm.ShowDialog() == DialogResult.OK)
            {
                string CreateFilePath = FileSystemTV.SelectedNode.FullPath + '\\' + NewForm.FileName;
                try
                {
                    FileManagerInstance.CreateFile(CreateFilePath, false, DiskInode.FileType.Index); //文件夹不允许覆盖
                    ListFile(FileSystemTV.SelectedNode);                                             //创建完成,刷新目录
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            CheckSpaceUsage();
        }