我需要制作一个转换工具,首先说我是菜鸟,下面的代码都是查资料编写出来的。
打开文件的模块已经写好了,
“开始转换”的那个模块最难,我还没开始,在开始之前我想先测验能否正确读取csv里的数据,结果是虽然能正确读取我想要的行,但可惜我用showbox测试输出的是乱码,现在的问题是如何让showbox输出正确的文字?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;namespace POP3通讯簿自动制作
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//选取由Exchange管理器导出的csv文件路径
private void button1_Click(object sender, EventArgs e)
{
string resultFile = "";
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "All files (*.*)|*.*|csv files (*.csv)|*.csv";
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
resultFile = openFileDialog1.FileName;
select_file_path.Text = resultFile;
}
//选取转换后的文件的保存路径
private void button2_Click(object sender, EventArgs e)
{
string resultPath = "";
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
//folderBrowserDialog1.RootFolder = "";
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
resultPath = folderBrowserDialog1.SelectedPath;
save_file_path.Text = resultPath;
}
//开始转换
private void btn_create_Click(object sender, EventArgs e)
{
string[] lines = System.IO.File.ReadAllLines(select_file_path.Text);
int formatingline=2;
everylinedatadispose(lines,formatingline);
}
static void everylinedatadispose(string[] line, int formatline)
{
MessageBox.Show(line[formatline]);
}
}
}
打开文件的模块已经写好了,
“开始转换”的那个模块最难,我还没开始,在开始之前我想先测验能否正确读取csv里的数据,结果是虽然能正确读取我想要的行,但可惜我用showbox测试输出的是乱码,现在的问题是如何让showbox输出正确的文字?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;namespace POP3通讯簿自动制作
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//选取由Exchange管理器导出的csv文件路径
private void button1_Click(object sender, EventArgs e)
{
string resultFile = "";
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "All files (*.*)|*.*|csv files (*.csv)|*.csv";
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
resultFile = openFileDialog1.FileName;
select_file_path.Text = resultFile;
}
//选取转换后的文件的保存路径
private void button2_Click(object sender, EventArgs e)
{
string resultPath = "";
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
//folderBrowserDialog1.RootFolder = "";
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
resultPath = folderBrowserDialog1.SelectedPath;
save_file_path.Text = resultPath;
}
//开始转换
private void btn_create_Click(object sender, EventArgs e)
{
string[] lines = System.IO.File.ReadAllLines(select_file_path.Text);
int formatingline=2;
everylinedatadispose(lines,formatingline);
}
static void everylinedatadispose(string[] line, int formatline)
{
MessageBox.Show(line[formatline]);
}
}
}
解决方案 »
- 请问UDP打洞需要哪些条件?获得外网IP还不算数吗?
- 打开VS2005设计窗体出错
- winform中webrequest超时问题
- c# TCP/IP多客户端连接问题
- 谁有sourcegrid或者MSFlexGrid合并单元格的事例!急急!!!
- C#程序中的Button按钮实现键盘上的退格键效果怎么做
- 求教高手,2000可以2005不行,System.Data.ReadOnlyException: 列为只读
- session问题
- DEBUG和RELEASE有何不同?
- c/s结构左边不变,右边根据toolstip显示不同的界面如何实现
- C#读取Excel表中的数据时,为何有些行的字段内容读取不到>?
- 关于Remoting的应用!
比如有个字符串:
存时进行System.Web.HttpUtility.UrlEncode(strAbc, System.Text.Encoding.UTF8);取时:System.Web.HttpUtility.UrlDecode(strAbc, System.Text.Encoding.UTF8);
public static string[] ReadAllLines (
string path,
Encoding encoding
)
System.IO.File.ReadAllLines(path, System.Text.Encoding.GetEncoding("GB2312"));
非accii的,最好写上编码方式。