当前位置: 代码迷 >> ASP.NET >> .txt文本导入SQL数据库的有关问题
  详细解决方案

.txt文本导入SQL数据库的有关问题

热度:3072   发布时间:2013-02-26 00:00:00.0
.txt文本导入SQL数据库的问题
已经有一个文本文档,想把里面的文字导入到数据库中,为了做一个简体字繁体字转化的东西,文本文档中的文字是没有分隔符的,导入数据库中要一个字为一条数据。应该怎么做呢?

------解决方案--------------------------------------------------------
C# code
namespace ConsoleApplication5{    class Program    {        static void Main(string[] args)        {            using (StreamReader sr = new StreamReader("a.txt", Encoding.Default))            {                char[] charArr = sr.ReadToEnd().Replace("\r\n", "\n").ToCharArray();                foreach (char item in charArr)                {                    if (!item.Equals('\n'))                    {                        Console.WriteLine(item);                    }                }            }            Console.Read();        }    }}
  相关解决方案