如果以打开文件的方式在文件框中显示HTML文件的代码 一、实现的效果是,当点击一个按钮时,打开“打开文件”对话框,然后选中一个HTML文件点“打开”后在文本框中显示出来当前打开文件的HTML源代码!! 30分二、(问题如上)但实现不用打开,直接用拖拽文件到文本框中并且显示HTML源代码!! 40分 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 textBox1.Text = yourStreamReader.ReadToEnd(); private string ReadFile(string file) { System.IO.TextReader txt = new System.IO.StreamReader(file); string s= txt.ReadToEnd(); txt.Close(); return s; } private void textBox1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop) ) { e.Effect = DragDropEffects.All; } } private void textBox1_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] MyFiles = (string[])e.Data.GetData(DataFormats.FileDrop); string strText = ""; for (int i = 0; i < MyFiles.Length; i++) { strText += ReadFile(MyFiles[i]); } textBox1.Text = strText; } } private void Form1_Load(object sender, EventArgs e) { textBox1.AllowDrop = true; textBox1.Multiline = true; } 请问下大们Handle具体有些什么用? C# 子窗体关闭时改变父窗体控件的值 求教,关于TabControll的问题 datatable导入到dsoframer中 问路:怎么样学习P2P? 谁有《Visual c#2005编程技巧大全》的电子书? C#中改变浮点数精度的方法是什么? 字符串问题,谢谢 ★★★★★高分求设计方案(特急)-- 在线等待★★★★★ *.css是什么文件,起什么作用. 使用log4net进行日志记录 继续下午的问题
{
System.IO.TextReader txt = new System.IO.StreamReader(file);
string s= txt.ReadToEnd();
txt.Close();
return s;
} private void textBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) )
{
e.Effect = DragDropEffects.All;
}
} private void textBox1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] MyFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
string strText = "";
for (int i = 0; i < MyFiles.Length; i++)
{
strText += ReadFile(MyFiles[i]);
} textBox1.Text = strText;
}
} private void Form1_Load(object sender, EventArgs e)
{
textBox1.AllowDrop = true;
textBox1.Multiline = true;
}