zoukankan      html  css  js  c++  java
  • 文件读入简单操作(C#)

    1

    2

    3

    4

    后台简单代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    namespace FileAction
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void btnChooseOpenFile_Click(object sender, EventArgs e)
            {
                OpenFileDialog ofd = new OpenFileDialog();
              
    
                if (ofd.ShowDialog() == DialogResult.OK) {
                    txtFilePathOpen.Text = ofd.FileName;
                }
    
            }
    
            private void btnSave_Click(object sender, EventArgs e)
            {
                string strContent = txtInputSave.Text.Trim();
                using(FileStream fs = new FileStream(txtFilePathOpen.Text, FileMode.Create))
                {
                    //将字符串转化成数组
                    byte[] byteFile = Encoding.UTF8.GetBytes(strContent); 
                    //要写入到文件的数据数组,从数组的第几个开始写,一共写入多少字节
                    fs.Write(byteFile, 0, byteFile.Length);
                     MessageBox.Show("保存成功");
                }
     
            }
        }
    }
    

      

  • 相关阅读:
    【js效果】密码的显示和隐藏
    【js效果】竖向折叠二级菜单
    【js效果】单行文字滚动(从左到右)
    mysql:查询排名
    init_bootmem_node
    bootmem_init_node
    for_each_node(node)
    build_mem_type_table
    __vet_atags
    asm-offset.h 生成
  • 原文地址:https://www.cnblogs.com/yzenet/p/2946943.html
Copyright © 2011-2022 走看看