怎么将输入内容修改为保存到本地

现在我这代码是输入内容用Codesoft打印出来,现在想修改为将输入内容保存为.txt格式到本地或网络盘,如txtTargetQty为4则每输入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;
using System.Data.OleDb;
using System.Diagnostics;
using System.Web;
using System.Net;
using System.Collections;

namespace PrintSN
{
public partial class MainForm : Form
{
private DataTable myDs = new DataTable();

    public MainForm()
    {
        InitializeComponent();
    }

    private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
    {
        if (e.KeyChar == (char)Keys.Enter)
        {
            string strInput = txtInput.Text;
            txtTargetQty.Text = Common.getConfigValueKey("PrintSNCount");
            if (strInput.Equals("UNDO"))
            {
                undo();
                txtInput.SelectAll();
                txtInput.Focus();
                return;
            }
            else
            {
                if (dataGridView1.Rows.Count >0)
                {
                    string strSN = "";
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        strSN = dataGridView1.Rows[i].Cells[0].Value.ToString();
                        if (strInput.Equals(strSN))
                        {
                            ShowInformation("SN 重复,请扫描其他的SN ! ", "NG");
                            txtInput.SelectAll();
                            txtInput.Focus();
                            return;
                        }
                    }
                }
                if (txtScanQty.Text.Equals((Int32.Parse(txtTargetQty.Text) - 1).ToString()))
                {
                    int index = this.dataGridView1.Rows.Add();
                    this.dataGridView1.Rows[index].Cells[0].Value = strInput;
                    ArrayList SnDetail = new ArrayList(); 
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {  
                        SnDetail.Add(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    }  
                    SoftCodePrint Print = new SoftCodePrint();
                    Print.PrintSNLabel(strInput, SnDetail);
                    txtScanQty.Text = "0";
                    dataGridView1.Rows.Clear();
                    ShowInformation("打印完成,请扫描的下一個SN ! ", "OK");
                }
                else
                {
                    txtScanQty.Text = (Int32.Parse(txtScanQty.Text) + 1).ToString();
                    ShowInformation("请扫描的下一個SN ! ", "OK");
                    int index = this.dataGridView1.Rows.Add();
                    this.dataGridView1.Rows[index].Cells[0].Value = strInput;


                }

                txtInput.SelectAll();
                txtInput.Focus();
                return;
            }

        }

    }

    private void undo()
    {
        //txtTargetQty.Text = "";
        txtScanQty.Text = "0";
        dataGridView1.Rows.Clear();
        ShowInformation("UNDO 操作成功,請掃描 SN! ", "OK");
    }

    private void ShowInformation(string sInfo, string sType)
    {
        lblShowMessageInfo.Text = sInfo;

        if (sType.Equals(""))
        {
            lblShowMessageInfo.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
        }
        if (sType.Equals("OK"))
        {
            lblShowMessageInfo.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
        }
        if (sType.Equals("NG"))
        {
            lblShowMessageInfo.BackColor = System.Drawing.Color.Red;
        }

    }

    private void MainForm_Load(object sender, EventArgs e)
    {
        txtTargetQty.Text = Common.getConfigValueKey("PrintSNCount");
    }

    private void MainForm_Shown(object sender, EventArgs e)
    {
        txtInput.SelectAll();
        txtInput.Focus();
    }

}

}


System.IO.File.WriteAllText(文件名, 你要保存的字符串);