zoukankan      html  css  js  c++  java
  • C#之读取文件路径

    读取文件时,路径的设置下面3种都可以:

    View Code
    protected void ReadUserName()
    {
    //string path = "c:\\temp/passport.txt";
    //string path = "c:/temp/passport.txt";
    string path = "c:\\temp\\passport.txt";
    int maxNum = 0;
    using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding("gb2312")))
    {
    string uname;
    while ((uname = sr.ReadLine()) != null)
    {
    maxNum
    ++;
    uname
    = uname.Split(',')[1];
    }
    }
    Assert.AreEqual(
    2, maxNum);
    }

    使用TestDriven.NET 3 单元测试

    1 在安装目录TestDriven.NET 找到Nunit.Framwork.dll,在项目引用中添加

    2 测试类文件头添加using NUnit.Framework;

    3

    4 每一种都有可以测试通过

  • 相关阅读:
    高级打字机
    不等数列
    间谍网络
    医院设置
    题目编号生成器
    传纸条
    聪明的打字员
    倒水问题
    八数码难题
    生日蛋糕
  • 原文地址:https://www.cnblogs.com/zjwei55/p/2177071.html
Copyright © 2011-2022 走看看