找不到网络路径

时间:2013-09-03 06:25:40

标签: c#

我的代码中出现了错误,如下所示:这显示错误,指出文件和服务器的路径未正确定义。请帮我解决这个问题,请建议我一些异常检测代码来成功运行

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

0 个答案:

没有答案