C#的有关”(是否缺少 using 指令或程序集引用?)的问题。

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da... 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.StreamWriter;
namespace _4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void 统计ToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("共有" + listView1.Items.Count + "条记录", "信息提示", MessageBoxButtons.OK);
}
private void 写入ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (textBox1.Text == string.Empty & textBox2.Text == string.Empty & textBox3.Text == string.Empty)
{
MessageBox.Show("要写入的文件内容不能为空");
}
else
{
SaveFileDialog of = new SaveFileDialog();
of.Filter = "二进制文件(*.dat)|*.dat";
if (of.ShowDialog() == DialogResult.OK)
{
StreamWriter sw = new StreamWriter(of.FileName, true);
sw.WriteLine(textBox1.Text);
sw.WriteLine(textBox2.Text);
sw.WriteLine(textBox3.Text);
sw.Close();
textBox1.Text = string.Empty;
textBox2.Text = string.Empty;
textBox3.Text = string.Empty;
}
}
}
private void 读取ToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog1.Filter = "二进制文件(*.dat)|*.dat";
if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = string.Empty;
textBox2.Text = string.Empty;
textBox3.Text = string.Empty;
StreamReader sr = new StreamReader(of.FileName);
StreamReader st = new StreamReader(of.FileName);
StreamReader sd = new StreamReader(of.FileName);
textBox1.Text = sr.ReadToEnd();
textBox2.Text = st.ReadToEnd();
textBox3.Text = sd.ReadToEnd();
sr.Close();
st.Close();
sd.Close();
}
}

}
}
因为全部太长了 只截取有问题的部分 希望大虾们能看懂
展开
 我来答
百百mp3
2013-06-30 · TA获得超过854个赞
知道小有建树答主
回答量:901
采纳率:90%
帮助的人:541万
展开全部
..............
using System.Text;
using System.Windows.Forms;

using System.IO; //是System.IO不是System.StreamWriter

namespace _4
{
public partial class Form1 : Form
...............
更多追问追答
追问
修改为IO之后,还有错误
错误 1 当前上下文中不存在名称“OpenFileDialog1”
错误 3 当前上下文中不存在名称“of”
追答
你不是没有学过C#吧,从工具箱里拖个OpenFileDialog和SaveFileDialog并改下名字就可以了啊...
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
他花花吐蕊开开7403
推荐于2018-03-26 · 超过37用户采纳过TA的回答
知道答主
回答量:383
采纳率:0%
帮助的人:207万
展开全部
其实只把出错的提示贴出来就行,“是否缺少 using 指令或程序集引用”前面说的是啥,是啥缺少using指令
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
bluewater_52d1
2013-06-30 · TA获得超过256个赞
知道小有建树答主
回答量:798
采纳率:0%
帮助的人:192万
展开全部
using System.IO;
追问
修改为IO之后,还有错误
错误 1 当前上下文中不存在名称“OpenFileDialog1”
错误 3 当前上下文中不存在名称“of”
追答
添加OpenFileDialog控件

private void 读取ToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "二进制文件(*.dat)|*.dat";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ textBox1.Text = string.Empty; textBox2.Text = string.Empty;
textBox3.Text = string.Empty;
StreamReader sr = new StreamReader(openFileDialog1.FileName);
StreamReader st = new StreamReader(openFileDialog1.FileName);
StreamReader sd = new StreamReader(openFileDialog1.FileName);
textBox1.Text = sr.ReadToEnd(); textBox2.Text = st.ReadToEnd();
textBox3.Text = sd.ReadToEnd(); sr.Close(); st.Close(); sd.Close();
}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式