• 大小: 620KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: C#
  • 标签: TXT  C#  读写  GPS  

资源简介

基于C#的GPS的TXT文件读写,分割,可以大批量地进行TXT读写工作

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace txtread
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamWriter mySW;
                try
                {
                    mySW = File.CreateText(“F:\\jiekouC#\\txtread2\\out\\out.txt“);
                }
                catch
                {
                    Console.WriteLine(“创建失败“);
                    return;
                }
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(“F:\\jiekouC#\\txtread2“);
                double count1 = 0;
            foreach (System.IO.FileInfo fi in dir.GetFiles())
            {
                if (fi.Extension == “.txt“)
                {
                    string[] lines = System.IO.File.ReadAllLines(@fi.FullName);
                    List list = new List();
                    list.AddRange(lines);
                    for (int i = 1; i < list.Count; i++)
                    {
                        double lon1 = Convert.ToDouble(list[i].Substring(26 6));
                        double lat1 = Convert.ToDouble(list[i].Substring(38 10));
                        if (lon1 < 116.47 & lon1 > 116.3 & lat1 < 39.975&lat1>39.844)
                        {
                            mySW.WriteLine(list[i]);
                            count1 = count1 + 1;
                        }
                    }
                }
                Console.WriteLine(count1);
                Console.ReadKey();
            }
                mySW.Close();
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1167668  2012-11-01 00:00  txtread2\20121101000014.txt

     文件    1167540  2012-11-01 00:02  txtread2\20121101000205.txt

     文件      16384  2014-05-24 15:43  txtread2\out\out.txt

     文件       5632  2014-05-01 16:30  txtread2\txtread\bin\Debug\txtread.exe

     文件      13824  2014-05-01 16:30  txtread2\txtread\bin\Debug\txtread.pdb

     文件      11600  2014-05-24 15:07  txtread2\txtread\bin\Debug\txtread.vshost.exe

     文件        490  2010-03-17 22:39  txtread2\txtread\bin\Debug\txtread.vshost.exe.manifest

     文件       5776  2014-05-01 16:30  txtread2\txtread\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       1038  2014-05-24 15:07  txtread2\txtread\obj\x86\Debug\txtread.csproj.FileListAbsolute.txt

     文件       6952  2014-04-24 15:13  txtread2\txtread\obj\x86\Debug\txtread.csprojResolveAssemblyReference.cache

     文件       5632  2014-05-01 16:30  txtread2\txtread\obj\x86\Debug\txtread.exe

     文件      13824  2014-05-01 16:30  txtread2\txtread\obj\x86\Debug\txtread.pdb

     文件       1682  2014-05-01 16:30  txtread2\txtread\Program.cs

     文件       1346  2014-04-24 14:04  txtread2\txtread\Properties\AssemblyInfo.cs

     文件       2435  2014-04-24 14:04  txtread2\txtread\txtread.csproj

     文件        863  2014-04-24 14:04  txtread2\txtread.sln

    ..A..H.     15872  2014-05-24 15:43  txtread2\txtread.suo

     目录          0  2014-04-24 14:04  txtread2\txtread\obj\x86\Debug\TempPE

     目录          0  2014-05-01 16:30  txtread2\txtread\obj\x86\Debug

     目录          0  2014-04-24 23:46  txtread2\txtread\bin\Debug

     目录          0  2014-04-24 23:46  txtread2\txtread\obj\x86

     目录          0  2014-04-24 23:46  txtread2\txtread\bin

     目录          0  2014-04-24 23:46  txtread2\txtread\obj

     目录          0  2014-04-24 23:46  txtread2\txtread\Properties

     目录          0  2014-04-24 23:47  txtread2\out

     目录          0  2014-04-24 23:46  txtread2\txtread

     目录          0  2014-04-24 23:46  txtread2

----------- ---------  ---------- -----  ----

              2438558                    27



............此处省略0个文件信息

评论

共有 条评论