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 notepads
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
List<string> a = new List<string>();
private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();//创建对话框
open.InitialDirectory = @"C:\Documents and Settings\All Users\桌面"; //设置对话框路径
open.Title = "对话框1"; //对话框标题
open.Filter = "文本文档|*.txt|所有文件|*.*";
open.Multiselect = true; //多选
open.ShowDialog(); //打开对话框
//string[] paths = open.FileName;
string paths = open.FileName; //读取文件的全路径
if (paths == "") return;
using (FileStream file = new FileStream(paths, FileMode.OpenOrCreate, FileAccess.Read))
{
byte[] bytes = new byte[1024 * 1024 * 5];
int r = file.Read(bytes, 0, bytes.Length);
this.textBox1.Text = Encoding.Default.GetString(bytes, 0, r);
} string ax = Path.GetFileName(paths);
listBox1.Items.Add(ax);
a.Add(paths); } private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sd = new SaveFileDialog(); //创建
// 保存文件对话框
sd.InitialDirectory = @"C:\Documents and Settings\All Users\桌面"; //设置对话框路径
sd.Title = "对话框1"; //对话框标题
sd.Filter = "文本文档|*.txt|所有文件|*.*";
sd.ShowDialog();
string path = sd.FileName;
if (path == "") return;
using (FileStream fsv = new FileStream(path, FileMode.Create, FileAccess.Write))
{
byte[] bytes = Encoding.Default.GetBytes(this.textBox1.Text);
fsv.Write(bytes, 0, bytes.Length);
} } private void 自动换行ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (this.textBox1.WordWrap == true)
{
this.textBox1.WordWrap = false;
}
else { this.textBox1.WordWrap = true;
}
} private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fonts = new FontDialog(); fonts.ShowDialog();
this.textBox1.Font = fonts.Font;
} private void 颜色ToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog color = new ColorDialog();
color.ShowDialog();
this.textBox1.ForeColor = color.Color;
} private void 显示ToolStripMenuItem_Click(object sender, EventArgs e)
{ panel1.Show(); } private void Form1_Load(object sender, EventArgs e)
{
//string[] path = Directory.GetFiles(@"C:\Documents and Settings\All Users\桌面", "*.txt"); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{ } private void 隐藏ToolStripMenuItem_Click(object sender, EventArgs e)
{
panel1.Hide();
} private void textBox1_TextChanged(object sender, EventArgs e)
{ } private void listBox1_DoubleClick(object sender, EventArgs e)
{
string name = a[listBox1.SelectedIndex];
using (FileStream file = new FileStream(name, FileMode.OpenOrCreate, FileAccess.Read))
{
byte[] bytes = new byte[1024 * 1024 * 5];
int r = file.Read(bytes, 0, bytes.Length);
this.textBox1.Text = Encoding.Default.GetString(bytes, 0, r);
}
this.textBox2.Text = a[listBox1.SelectedIndex];
} private void button1_Click(object sender, EventArgs e)
{
string pat = this.textBox2.Text; //File.Delete(pat);
}
}
}

  

c#记事本的更多相关文章

  1. Notepad2替代系统自带的记事本

    事情是这样的,平时我经常把一些文字复制到记事本中编辑好了再复制到目标位置,可以在系统自带的记事本中替换删除一些内容,记事本小巧,占用很少的资源,我很喜欢:但今天复制的内容中有很多数字和一些我不想要的内 ...

  2. JAVA/GUI程序之记事本

    自上半年JAVA课程结束后,再也没有看过JAVA了,最近不是很忙,又简单的看了看,本博客纯属记录学习过程,请大神们别笑,其中错误是难免的,毕竟是新手写的博客.下面就进入我们的正题吧,复习GUI时,就想 ...

  3. HTML---用记事本写html

    <DOCTYPE HTML> <--DOCTYPE 文档类型,浏览器按照该类型解析--> <html> <head> <title>这个是h ...

  4. C++-Qt【2】-实现一个简单的记事本

    用Qt实现一个简单的记事本: #include "helloqt.h" #include <qfiledialog.h> #include <qfile.h> ...

  5. windows自带记事本导致文本文件(UTF-8编码)开头三个字符乱码问题

    在windows平台下,使用系统的记事本以UTF-8编码格式存储了一个文本文件,但是由于Microsoft开发记事本的团队使用了一个非常怪异的行为来保存UTF-8编码的文件,它们自作聪明地在每个文件开 ...

  6. winform记事本(基本功能)

    本题主要考察各种控件的应用 using System; using System.Collections.Generic; using System.ComponentModel; using Sys ...

  7. 大熊君大话NodeJS之------基于Connect中间件的小应用(Bigbear记事本应用之第一篇)

    一,开篇分析 大家好哦,大熊君又来了,昨天因为有点个人的事没有写博客,今天又出来了一篇,这篇主要是写一个记事本的小应用,前面的文章, 我也介绍过“Connect”中间件的使用以及“Mongodb”的用 ...

  8. 签名、BOM头、编码、Windows记事本编码、java编码解码的那些事

    对于Windows记事本: ANSI :GB2312 java中应使用GBK解码 Unicode :有签名的UTF-16LE java中应使用UTF-16解码 Unicode big endian : ...

  9. 转!!windows记事本保存“联通” 编码问题

    原博文网址:http://blog.csdn.net/Zhiyuan_Ma/article/details/51838054 简单分析: 这是微软记事本的一个BUG,准确点就是unicode编码的问题 ...

  10. win32记事本程序(二)

    遇到一个较大的难题,做记事本要不要使用edit或者是richedit控件呢.如果用控件的话感觉没什么挑战,不用控件,现有的参考资料仅有<windows程序设计>第六章的TYPER程序,这个 ...

随机推荐

  1. Java基础之访问文件与目录——移动或复制文件和目录(MoveAndCopyFiles)

    控制台程序,创建和删除目录以及复制和移动文件. import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOE ...

  2. linux:lnmp环境搭建

    一.准备工作(把安装环境需要使用到的包都下载好) mysql(官网):http://dev.mysql.com/downloads/ php(官网):http://php.net/downloads. ...

  3. C# 以管理员方式启动Winform,进而使用管理员控制Windows Service

    问题起因: 1,) 问题自动分析Windows服务在正常运行时,确实会存在程序及人为原因导致该服务停止.为了在应用程序使用时确保该服务正常运行,于是有了该讨论主题. 2,)一般账户(尽管是管理员组账户 ...

  4. poj 1731 Orders

    http://poj.org/problem?id=1731 Orders Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9 ...

  5. nyist 606 ACM之路

    http://acm.nyist.net/JudgeOnline/problem.php?pid=606 ACM之路 时间限制:1000 ms | 内存限制:65535 KB 描述 转眼间,12级新生 ...

  6. list和map的区别

    list和map的区别 list-->list是对象集合,允许对象重复 map-->map是键值对的集合,不允许key重复

  7. yii2封装一个类控制div宽度,高度

    1.首先,封装一个类,放在文件夹vendor下,命名为articls.php. <?phpclass Articles{ //测试    function add()    {        r ...

  8. springday04-go2

    练习:计算一个人的bmi指数.算法如下: 身高 单位是米 比如1.70 体重 单位是公斤 比如90 bmi指数 = 体重/身高/身高 如果bmi>24过重,否则正常.视图需要两个,一个是bmi_ ...

  9. spring da-y02-go1

    使用构造器实例化bean: springday02:(同样导入5个基本jar包)1.复制xml文件到ioc包下2.B类,实现无参构造器3.A类,B是它的成员变量,实现无参和set/get方法4.修改x ...

  10. paper 74:MATLAB图像处理_HSV与RGB颜色空间互转

    HSV空间:分别是H(色调)——S(饱和度)——V(亮度) 与HSI颜色空间类似:分别是H(色调)——S(饱和度)——I(强度) 注意: 强度和亮度差不多是一个概念. 饱和度代表的是渗入白光的数量级, ...