zoukankan      html  css  js  c++  java
  • C#文件操作

    文件的读取
     FileStream fs = new FileStream(@"D:12.txt", FileMode.Open);
                byte[] buffer = new byte[1024 * 1024];
                fs.Read(buffer, 0, buffer.Length);
                string content = Encoding.Default.GetString(buffer);
                textBox1.Text = content;
                fs.Dispose();

    文件的保存
     SaveFileDialog sfd = new SaveFileDialog();
                DialogResult rst = sfd.ShowDialog();
                if(rst==System.Windows.Forms.DialogResult.OK)
                {
                    FileStream fs = new FileStream(sfd.FileName,FileMode.Create);
                    string content = textBox1.Text;
                    byte[] buffer = ASCIIEncoding.UTF8.GetBytes(content);
                    fs.Write(buffer,0,buffer.Length);
                    fs.Dispose();

    文件的复制
    FileStream streamread = new FileStream(@"D:123.wmv",FileMode.Open);
                FileStream streamwrite = new FileStream(@"F:1212.wmv",FileMode.Create);
                byte[]buffer=new byte[1024*1024*3];
                int Length;
                do
                {
                    Length = streamread.Read(buffer,0, buffer.Length);
                    streamwrite.Write(buffer,0, Length);
                }
                while (Length == buffer.Length);
                streamread.Dispose();
                streamwrite.Dispose();
                MessageBox.Show("Copy Success");

  • 相关阅读:
    如何用vue做计算器功能
    js反弹运动
    $.each的使用
    js文字滚动事件
    根据服务器时间,计算出时间轴的倒计时。
    时间格式转时间戳的几种方法
    匀速运动升级
    js匀速运动
    js图片滚动无缝衔接
    webFrame
  • 原文地址:https://www.cnblogs.com/HorseKing/p/3550628.html
Copyright © 2011-2022 走看看