无用的

 

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"

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值