• Read and Write 单一文件


    private void operateFlatFile()
    {
        string path;
        FileStream fs;
        byte[] _read, _write;
        int start, end;

        start = 0;
        end = 50;

        // read
        path = Server.MapPath("http://www.cnblogs.com/document/encode.txt");
        fs = new FileStream(path, FileMode.Open);
        _read = new byte[end];

        fs.Read(_read, start, end);
        fs.Close();

        // print
        Encoding ur = Encoding.GetEncoding("gb2312");
        string content = ur.GetString(_read);
        Response.Write(content + "<br>");

        // write
        path = Server.MapPath("http://www.cnblogs.com/document/new.txt");
        fs = new FileStream(path, FileMode.OpenOrCreate) ;

        Encoding uw = Encoding.GetEncoding("utf-8") ;
        _write = uw.GetBytes(content);

        fs.Write(_write, start, _write.Length);
        fs.Close();

        // show message

        Response.Write( "succ.");
    }

  • 相关阅读:
    podfile 文件写法
    九大内置对象
    动态网页开发基础
    表单效验
    使用jQuery快速高效制作网页交互特效
    使用jQuery操作DOM
    jQuery选择器
    初始jQuery
    javaScript基础及初始面向对象
    JavaScript操作DOM对象
  • 原文地址:https://www.cnblogs.com/lovewife/p/1396463.html
Copyright © 2020-2023  润新知