c#记事本
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#记事本的更多相关文章
- Notepad2替代系统自带的记事本
事情是这样的,平时我经常把一些文字复制到记事本中编辑好了再复制到目标位置,可以在系统自带的记事本中替换删除一些内容,记事本小巧,占用很少的资源,我很喜欢:但今天复制的内容中有很多数字和一些我不想要的内 ...
- JAVA/GUI程序之记事本
自上半年JAVA课程结束后,再也没有看过JAVA了,最近不是很忙,又简单的看了看,本博客纯属记录学习过程,请大神们别笑,其中错误是难免的,毕竟是新手写的博客.下面就进入我们的正题吧,复习GUI时,就想 ...
- HTML---用记事本写html
<DOCTYPE HTML> <--DOCTYPE 文档类型,浏览器按照该类型解析--> <html> <head> <title>这个是h ...
- C++-Qt【2】-实现一个简单的记事本
用Qt实现一个简单的记事本: #include "helloqt.h" #include <qfiledialog.h> #include <qfile.h> ...
- windows自带记事本导致文本文件(UTF-8编码)开头三个字符乱码问题
在windows平台下,使用系统的记事本以UTF-8编码格式存储了一个文本文件,但是由于Microsoft开发记事本的团队使用了一个非常怪异的行为来保存UTF-8编码的文件,它们自作聪明地在每个文件开 ...
- winform记事本(基本功能)
本题主要考察各种控件的应用 using System; using System.Collections.Generic; using System.ComponentModel; using Sys ...
- 大熊君大话NodeJS之------基于Connect中间件的小应用(Bigbear记事本应用之第一篇)
一,开篇分析 大家好哦,大熊君又来了,昨天因为有点个人的事没有写博客,今天又出来了一篇,这篇主要是写一个记事本的小应用,前面的文章, 我也介绍过“Connect”中间件的使用以及“Mongodb”的用 ...
- 签名、BOM头、编码、Windows记事本编码、java编码解码的那些事
对于Windows记事本: ANSI :GB2312 java中应使用GBK解码 Unicode :有签名的UTF-16LE java中应使用UTF-16解码 Unicode big endian : ...
- 转!!windows记事本保存“联通” 编码问题
原博文网址:http://blog.csdn.net/Zhiyuan_Ma/article/details/51838054 简单分析: 这是微软记事本的一个BUG,准确点就是unicode编码的问题 ...
- win32记事本程序(二)
遇到一个较大的难题,做记事本要不要使用edit或者是richedit控件呢.如果用控件的话感觉没什么挑战,不用控件,现有的参考资料仅有<windows程序设计>第六章的TYPER程序,这个 ...
随机推荐
- 在相同的主机上创建一个duplicate数据库
在相同的主机上创建一个duplicate数据库 source db:dbtest auxiliary db:dupdb duplicate database会自动分配一个新的DBID要确保auxili ...
- XCODE中的蓝色文件夹与黄色文件夹
XCODE中的蓝色文件夹与黄色文件夹 黄色文件夹比较常见 - group , 在XCODE中以文件夹的形式存在,有层次感,但是实际文件在工程下是散乱的,没有层级结构.是XCODE中虚拟目录. 蓝色文件 ...
- Python:使用psycopg2模块操作PostgreSQL
安装psycopg2模块: 怎么验证是否已经安装过psycopy2? 编写上面代码,运行看是否抛出缺少psycopg2模块. 安装方法1: 1)使用psycopg2-2.4.2.win-amd64-p ...
- ios app 解决微信扫二维码不能跳转问题
<script> (function(){ // Setup GA (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i ...
- [原创]java WEB学习笔记67:Struts2 学习之路-- 类型转换概述, 类型转换错误修改,如何自定义类型转换器
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- linux环境变量与本地变量
两者不同的是. 环境变量可以在shell的子进程中使用, 而本地变量不同. 每当连接上服务器时,服务器就会通过帐号密码运行一个SHELL,我们所做的工作都在这个SHELL上,特殊方法除外(如,守护进程 ...
- 服务器 CentOS上yum安装Nginx服务
一.更改yum源为网易的源加快速度 vi /etc/yum.repos.d/CentOS-Base.repo 更改内容如下 # CentOS-Base.repo # # This file uses ...
- CSS_03_01_CSS选择器中单选择器:关联选择器档
选择器中单选择器:关联选择器档 第01步:编写select.css @charset "utf-8"; /* span标签中的b标签的exam类 */ span b.exam{ b ...
- JAVA面试题之实现字符串的倒序输出
package shb.java.demo; public class MyTest { public static void main(String[] args) { String string ...
- datagridview 用法
标签:c# datagridview 用法 拖一个datagridview控件 初始的名字叫dataGridView1 准备工作: 点击控件右上角的三角,选择“添加列”添加表头的项 基本操作: ...