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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//filestream file =new filestream("",FileMode.Open,FileAccess.Read);
filestream file = new filestream();
}
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
fd.InitialDirectory = Application.StartupPath;
fd.Filter = "textFile|*.txt;*.ini";
if (fd.ShowDialog() == DialogResult.OK) {
loadInfo(fd.FileName);
}
}
public void loadInfo(string path) {
StreamReader fm = new StreamReader(path, System.Text.Encoding.Default);
string str ;
string PathName=string.Empty;
while((str=fm.ReadLine())!=null){
//Console.WriteLine(str);
if (str.StartsWith(";") || str.StartsWith("/"))
{
}
else {
if (str.StartsWith("["))
{
//Console.WriteLine(str.Substring(1, str.LastIndexOf("]")-1));
PathName=str.Substring(1, str.LastIndexOf("]")-1);
//Console.WriteLine(str.Substring(0, str.LastIndexOf("=")));
/* if (str.LastIndexOf("="))
{
}*/
}else{
Console.WriteLine(str);
writeCSV( PathName , str);
}
//foreach (string item in str.Split(' '))
//{
// Console.WriteLine(item);
//}
}
}
}
private void writeCSV(string path,string file){
//file save path
String pathName;
if (path.Equals(string.Empty))
{
//Todo:exception
}
else
{
try
{
//file Name plus file Path
pathName = path + "_" + file.Substring(0, file.LastIndexOf("="));
pathName = Application.StartupPath + pathName + ".csv";
//delete file Name parts
file = file.Substring(file.LastIndexOf("=")+1);
//file create
StreamWriter f_srm = new StreamWriter(pathName);
//
Console.WriteLine(pathName);
try
{
foreach (string item in file.Split(' '))
{
//Console.WriteLine(item.Substring(0, 1) + "," + item.Substring(1));
f_srm.WriteLine(item.Substring(0, 1) + "," + item.Substring(1));
}
}
catch (Exception)
{
f_srm.Close();
//throw;
return;
}
f_srm.Close();
}
catch (Exception)
{
// throw;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER/Software/Microsoft/VisualStudio/8.0/Text Editor]
"Guides"="RGB(0, 0, 255) 100"