zoukankan      html  css  js  c++  java
  • 读取文件txt

            /// <summary>
            /// 读取文件
            /// </summary>
            /// <param name="path"></param>
            /// <returns></returns>
            public static String ReadFile()
            {
                string path = AppDomain.CurrentDomain.BaseDirectory+"data.txt";
                Log(path);
                Log(File.Exists(path)?"存在":"不存在");
                if (File.Exists(path))
                {
       
                    byte[] byData = new byte[1000];
                    char[] charData = new char[10000];
                    try
                    {
                        StreamReader sr = new StreamReader(path, Encoding.Default);
                        String line;
                        var result = "";
                        while ((line = sr.ReadLine()) != null)
                        {
                            result+=line;
                        }
                        Log(result);
                        return result;
                    }
                    catch (IOException e)
                    {
                        Log(e.Message);
                        return "";
                    }
                }
                return "";
            }

  • 相关阅读:
    ActiveMQ的用途
    HTTP 状态码的完整列表
    Linux中脚本运行错误(坏的解释器:没有那个文件或目录)
    Linux下ping: unknown host www.baidu.com的解决办法
    python中的collection
    Table里嵌套ASPXGridView
    致2015
    WPF学习之Binding(二)
    WPF学习之Binding(一)
    WPF UI布局(Layout)
  • 原文地址:https://www.cnblogs.com/change4now/p/5665199.html
Copyright © 2011-2022 走看看