• 大小: 29KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C#
  • 标签: C#  文本  信息修改  另存  

资源简介

C# Winform 发票信息修改 文本内容修改 指定文本覆盖 文件名修改 另存 保存

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Invoice_info_amend
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender EventArgs e)
        {

        }

        private void button2_Click(object sender EventArgs e)
        {
            string bak = Application.StartupPath + DateTime.Now.ToString(“yyyy-MM-dd“) + “.txt“;
            //string path = “E:\\GPO\\Regional\\“;
            string path = textBox8.Text+“\\“;
            string[] pathFile = Directory.GetFiles(path);
            //string newpath = “E:\\GPO\\Mend\\“;
            string newpath = textBox9.Text+“\\“;
            string con = ““;
            int i = 0;
            foreach (string str in pathFile)
            {
                FileStream fs = new FileStream(str FileMode.Open FileAccess.Read);
                StreamReader sr = new StreamReader(fs);
                //Encoding enc =  System.Text.Encoding.GetEncoding(fs);
                string[] lines = File.ReadAllLines(str);
                string filename = System.IO.Path.GetFileNameWithoutExtension(str);
                textBox1.Text = filename;
                string[] sArray = filename.Split(new char[] { ‘_‘ });
                textBox2.Text = textBox4.Text + “_“ + textBox5.Text;
                textBox3.Text = sArray[0];
                //textBox5.Text = sArray[1];
                textBox6.Text = lines[0];
                textBox4.Text = System.Text.Regularexpressions.Regex.Replace(textBox6.Text @“[^0-9]+“ ““);
                string hm = lines[1];
                textBox5.Text = System.Text.Regularexpressions.Regex.Replace(hm @“[^0-9]+“ ““);
                //textBox3.Text = System.Text.Regularexpressions.Regex.Replace(textBox4.Text @“[^0-9]+“ ““);
                con = sr.ReadToEnd();
                con = con.Replace(textBox3.Text textBox4.Text);
                //con = con.Replace(con textBox1.Text textBox2.Text);
                sr.Close();
                fs.Close();
                FileStream ba = new FileStream(bak FileMode.Append FileAccess.Write);
                StreamWriter ba2 = new StreamWriter(ba);
                ba2.WriteLine(filename);
                ba2.Close();
                ba.Close();
                FileStream fs2 = new FileStream(newpath + textBox4.Text + “_“ + textBox5.Text + “.txt“ FileMode.Create FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs2 System.Text.Encoding.Unicode);
                sw.WriteLine(con);
                sw.Close();
                fs2.Close();
                string photo1 = path + filename + “.jpg“;
                string photo2 = newpath + textBox4.Te

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        187  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\App.config

     文件       3408  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\Form1.cs

     文件      14363  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\Form1.Designer.cs

     文件       5817  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\Form1.resx

     文件       3815  2019-04-10 22:22  Invoice_info_amend\Invoice_info_amend\Invoice_info_amend.csproj

     文件       1308  2019-04-22 15:14  Invoice_info_amend\Invoice_info_amend\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7120  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        976  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug\Invoice_info_amend.csproj.FileListAbsolute.txt

     文件        975  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug\Invoice_info_amend.csproj.GenerateResource.Cache

     文件      14336  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug\Invoice_info_amend.exe

     文件        180  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug\Invoice_info_amend.Form1.resources

     文件      24064  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug\Invoice_info_amend.pdb

     文件        180  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug\Invoice_info_amend.Properties.Resources.resources

     文件          0  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件        530  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Program.cs

     文件       1356  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Properties\AssemblyInfo.cs

     文件       2888  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Properties\Resources.Designer.cs

     文件       5612  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Properties\Resources.resx

     文件       1105  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Properties\Settings.Designer.cs

     文件        249  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Properties\Settings.settings

     文件        944  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend.sln

    ..A..H.     36352  2019-04-23 17:58  Invoice_info_amend\Invoice_info_amend.v11.suo

     目录          0  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\obj\Debug\TempPE

     目录          0  2019-04-23 10:43  Invoice_info_amend\Invoice_info_amend\obj\Debug

     目录          0  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\obj

     目录          0  2019-04-10 22:12  Invoice_info_amend\Invoice_info_amend\Properties

     目录          0  2019-04-23 17:58  Invoice_info_amend\Invoice_info_amend

     目录          0  2019-04-10 22:12  Invoice_info_amend

............此处省略3个文件信息

评论

共有 条评论