android简单记事本小程序,一个简单的记事本小程序源码

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;

namespace txtWrite

{

public partial class Form1 : Form

{

private string currentFilePath;//存储打开文件的字段

public Form1()

{

InitializeComponent();

}

//打开文件

private void tspOpen_Click(object sender, EventArgs e)

{

if (ofdFile.ShowDialog() == DialogResult.OK)

{

getFileName(ofdFile.FileName);

txtFile.Text = File.ReadAllText(currentFilePath);

}

}

//保存

private void tsmSave_Click(object sender, EventArgs e)

{

File.WriteAllText(currentFilePath, txtFile.Text);

}

//另存为

private void tsmSaveas_Click(object sender, EventArgs e)

{

if (sfdSave.ShowDialog() == DialogResult.OK)

{

File.WriteAllText(sfdSave.FileName, txtFile.Text);

getFileName(sfdSave.FileName);

}

}

private string getFileName(string filePath)

{

currentFilePath = filePath;

string filename = Path.GetFileName(currentFilePath);//从一个完整路径中取出文件名

this.Text = filename + "-简单的记事本";

return currentFilePath;

}

private void tsmExit_Click(object sender, EventArgs e)

{

Application.Exit();

}

//复制

private void cOPYToolStripMenuItem_Click(object sender, EventArgs e)

{

txtFile.Copy();

}

//粘贴

private void tsmPaste_Click(object sender, EventArgs e)

{

txtFile.Paste();

}

//剪切

private void tsmCut_Click(object sender, EventArgs e)

{

txtFile.Cut();

}

}

}

本人相当的菜鸟,高手见了本文莫笑!

刚刚学c#不久

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值