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程序,这个 ...
随机推荐
- Java基础之处理事件——使用适配器类(Sketcher 3 using an Adapter class)
控制台程序. 适配器类是指实现了监听器接口的类,但监听器接口中的方法没有内容,所以它们什么也不做.背后的思想是:允许从提供的适配器类派生自己的监听器类,之后再实现那些自己感兴趣的类.其他的空方法会从适 ...
- CSS位置如何获取的
- Lintcode: Subarray Sum Closest
Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first nu ...
- csuoj 1113: Updating a Dictionary
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1113 1113: Updating a Dictionary Time Limit: 1 Sec ...
- [转]JqueryEasyUI教程入门篇
什么是jQueryEasyUI? JqueryUI是一组基于jQuery的UI插件集合 学习jQueryEasyUI的条件? 必须掌握Jquery的基本语法知识 jQueryEasyUI的特点? 1. ...
- 数据库SQL 查询
查询 1.简单查询 select * from info(表名) --查所有数据 select code(列名),name(列名) from 表名 --查指定列的数据 selec ...
- 关于内存 GetMemory( ) 笔试分析
1. #include<stdio.h>#include<string.h>void GetMemory(char *p){ p=(char *)malloc(100); }i ...
- mldn android
ed2k://|file|%E9%AD%94%E4%B9%90%E7%A7%91%E6%8A%80_Android%E5%BC%80%E5%8F%91%E5%AE%9E%E6%88%98%E7%BB% ...
- C#写好的类库dll怎么在别人调用的时候也能看到注释?
菜单 Project -> 'xxxx' Properties -> Build -> Output -> 勾上 XML Documentation file
- (转)oracle 查看表所占用的空间大小
1.查看表所占空间 SELECT TABLESPACE_NAME,TO_CHAR(SUM(BYTES)/(1024*1024),'999G999D999') CNT_MB FROM ...