Beispiel #1
0
 //listBox的item双击事件
 void ListFilesDoubleClick(object sender, EventArgs e)
 {
     if (listFiles.SelectedItem == null)
     {
         return;
     }
     else
     {
         if (listFiles.SelectedItem.ToString().Contains("【文件夹】"))
         {
             string temp = listFiles.SelectedItem.ToString().Replace("【文件夹】", "");
             lblPath.Text = lblPath.Text + temp + "\\";
             show(lblPath.Text);
         }
         else if (listFiles.SelectedItem.ToString().Contains(".txt"))
         {
             FormTxtReader formTxtReader = new FormTxtReader(lblPath.Text + listFiles.SelectedItem.ToString());
             formTxtReader.Text = lblPath.Text + listFiles.SelectedItem.ToString();
             formTxtReader.Show();
         }
         else
         {
             return;
         }
         btnSearchFile.Text = "查找文件";
         txtFileName.Text   = "";
         gBoxAttri.Visible  = false;
         txtRename.Text     = "";
     }
 }
Beispiel #2
0
        /// <summary>
        /// 新建文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            string fullName = lblPath.Text + txtNewFile.Text + ".txt";

            try
            {
                if (txtNewFile.Text == "")
                {
                    MessageBox.Show("请输入要新建的文件名!", "提示");
                    return;
                }
                using (FileStream file = new FileStream(fullName, FileMode.CreateNew))
                {
                    show(lblPath.Text);
                }
                FormTxtReader formTxtReader = new FormTxtReader(fullName);
                formTxtReader.Text = fullName;
                formTxtReader.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建文件失败:" + ex.Message, "提示");
            }
        }