namespace 邮件处理
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
try
{
folderBrowserDialog1.ShowDialog();
textBox1.Text = folderBrowserDialog1.SelectedPath;
DirectoryInfo DInfo = new DirectoryInfo(textBox1.Text);
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
this.listBox1.Items.Clear();
for (int i = 0; i < FSInfo.Length; i++)
{
listBox1.Items.Add( FSInfo[i].ToString() + "\n");
}
}
catch { MessageBox.Show("请选择文件夹"); }
} private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.listBox1.SelectedItem != null)
{
string path = “地址”
try{
FileStream fs = File.OpenRead(path);
byte[] b = new byte[1024];
//UTF8Encoding temp = new UTF8Encoding(true); while (fs.Read(b,0,b.Length) > 0)
{
Console.WriteLine(temp.GetString(b));
}
richTextBox1.Text = Encoding.Default.GetString(b);
//richTextBox1.Text = listBox1.SelectedValue.ToString();
}
catch { MessageBox.Show("请选择文件"); }
}
}
}
}我想实现在本地处理邮件,用了一个LISTBOX选择项,一个选路径,一个RICHTEXTBOX显示邮件内容,我想实现的是当选择好路径文件夹后在listbox中显示文件夹中的邮件列表,这个已经实现,想实现在选中listbox邮件时同时在RICHTEXTBOX中显示邮件内容,怎么实现,怎么关联??string path中的地址怎么关联,困扰好几天了,最好能有代码,请大家帮帮忙
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void button1_Click(object sender, EventArgs e)
{
try
{
folderBrowserDialog1.ShowDialog();
textBox1.Text = folderBrowserDialog1.SelectedPath;
DirectoryInfo DInfo = new DirectoryInfo(textBox1.Text);
FileSystemInfo[] FSInfo = DInfo.GetFileSystemInfos();
this.listBox1.Items.Clear();
for (int i = 0; i < FSInfo.Length; i++)
{
listBox1.Items.Add( FSInfo[i].ToString() + "\n");
}
}
catch { MessageBox.Show("请选择文件夹"); }
} private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.listBox1.SelectedItem != null)
{
string path = “地址”
try{
FileStream fs = File.OpenRead(path);
byte[] b = new byte[1024];
//UTF8Encoding temp = new UTF8Encoding(true); while (fs.Read(b,0,b.Length) > 0)
{
Console.WriteLine(temp.GetString(b));
}
richTextBox1.Text = Encoding.Default.GetString(b);
//richTextBox1.Text = listBox1.SelectedValue.ToString();
}
catch { MessageBox.Show("请选择文件"); }
}
}
}
}我想实现在本地处理邮件,用了一个LISTBOX选择项,一个选路径,一个RICHTEXTBOX显示邮件内容,我想实现的是当选择好路径文件夹后在listbox中显示文件夹中的邮件列表,这个已经实现,想实现在选中listbox邮件时同时在RICHTEXTBOX中显示邮件内容,怎么实现,怎么关联??string path中的地址怎么关联,困扰好几天了,最好能有代码,请大家帮帮忙
解决方案 »
- 谁能用CodeDom描述这种语法:object o=new object(){val=""}
- 高手请进-有关类对象的问题
- 应该使用哪种型号的刷卡器?
- 两种程序的整合
- 使用DataSet和DataGridView时手动插入数据的问题!
- 在使用NHibernate时出现SqlClient异常,我想看一下NHibernate给我生成的SQL语句,如何察看?
- 从DataSet写入xml文件的问题
- 我想和各位大侠请教有关数据感知的问题
- visual studio.net msdn查看好多文档为什么老是报这个错
- 循环播放图片,为什么总是显示一张。另外一张,只看到一闪屏幕.谢谢呀
- 连接ACCESS数据库是发生错误,请指教。
- 求一句话vb转 c#.net
{
string s=listBox1.SelectedItem.ToString();
//查询获取邮件内容
}
这句什么意思,哪里需要这句呢
{
if (this.listBox1.SelectedItem != null)
{
string path = listBox1.selectedItem.ToString();这个地址对不对呢,listBox1.SelectedItem.value好像没有这样用的吧,报错
try{
FileStream fs = File.OpenRead(path);
byte[] b = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);//这句话什么意思,不用可以吗 while (fs.Read(b,0,b.Length) > 0)
{
Console.WriteLine(temp.GetString(b));
}
richTextBox1.Text = Encoding.Default.GetString(b);要改成+=??好像还是有问题啊
//richTextBox1.Text = listBox1.SelectedValue.ToString();这句话对不对,能不能在richTextBox1中显示选中的邮件内容呢
}
catch { MessageBox.Show("请选择文件"); }
}
谁能帮我验证下啊,给个完整的代码,谢谢啊,这些代码都是我上网找的,拼凑起来的,也不是很明白