1

以下のコードにエラーがありました。これは、ファイルとサーバーへのパスが正しく定義されていないというエラーを示しています。この問題を解決するのを手伝ってください。それ以外の場合は、正常に実行するための異常検出コードを提案してください

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using System.IO.Ports;
namespace DDOS
{
    public partial class client : Form
    {

        SqlCommand cmd;
        SqlDataReader dr;
        SqlConnection cn;
        public static string fileName;
        public static string Servername;
        string path;
        public client()
        {
            InitializeComponent();
        }

        private void login_Load(object sender, EventArgs e)
        {
            txtUname.Enabled = true;
            btnLogin.Enabled = true;
        }

        public void btnLogin_Click(object sender, EventArgs e)
        {
            cn = new SqlConnection("Data Source=MANIKANDAN-PC\\SQLEXPRESS;InitialCatalog=DDOS;Integrated Security=True");
            cn.Open();
            string server = "" + txtUname.Text + ".txt";
            Servername = "" + textBox1.Text + "";
            string path3 = "\\\\" + Servername + "/REPUTE/" + server + "";
            if (System.IO.File.Exists(path3))
            {
                lblError1.Text = "";
                lblError1.Text = "Contact Admin To use the tool";
                txtUname.Text = "";
                txtPass.Text = "";

            }
            else

            {
                        fileName = "uname.txt";
                        Servername = "" + textBox1.Text + "";
                        path = "\\\\" + Servername + "/REPUTE/" + fileName + "";
                        FileStream fileStr = new FileStream(path, FileMode.Create, FileAccess.Write);
                        StreamWriter sw = new StreamWriter(fileStr);
                        sw.Write(txtUname.Text);
                        sw.Close();
                        fileStr.Close();
                        sendFile objsendfile = new sendFile();
                        objsendfile.Show();
            }
        }//i have error in this area
4

0 に答える 0