示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtFileName.Text == "")
            {
                MessageBox.Show("File Name Field is Blank");
            }
            else if (txtFileName.Text != "")
            {
                fileName = txtFileName.Text + ".txt";
            }

            string str = @path + "\\" + fileName;

            try
            {
                if (File.Exists(str))
                {
                    MessageBox.Show("File Already Exists, Rename The File");
                }
                else
                {
                    string dsPath = @"H:\InnerCloudDB\" + str.Substring(pathCount);

                    using (StreamWriter sw = File.CreateText(str))
                    {
                        sw.WriteLine(txtData.Text);
                    }
                    using (StreamWriter sw = File.CreateText(dsPath))
                    {
                        sw.WriteLine(txtData.Text);
                    }
                    MessageBox.Show("File Has Been Created");

                    Homepage hm = new Homepage();
                    hm.Visible = true;
                    hm.LoadFileList(path);
                    this.Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtFileName.Text == "")
            {
                MessageBox.Show("File Name Field is Blank");
            }
            else if (txtFileName.Text != "")
            {
                fileName = txtFileName.Text + ".txt";
            }

            string str = @path + "\\" + fileName;

            try
            {
                if (File.Exists(str))
                {
                    File.Delete(str);
                }

                using (StreamWriter sw = File.CreateText(str))
                {
                    sw.WriteLine(txtData.Text);
                    MessageBox.Show("File Has Been Created");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Homepage hm = new Homepage();

            MessageBox.Show(path);
            hm.Visible = true;
            hm.LoadFileList(path);
            this.Visible = false;
        }