String passes different value than textbox C#

JuicyMike

Newcomer
Joined
May 9, 2012
Messages
2
I do reference another class named Config, but that is not where the problem lies. the issue is when the network path is passed through "Filename" it adds more "\"'s

Example
txtdataPath.Text ="\\server\folder\file"

If i were to put a linebreak over "Filename" it would read
\\\\server\\folder\\file


private void btnTest_Click(object sender, EventArgs e)
{

string Filename = txtdataPath.Text;
string un = txtuserName.Text;
string pw = txtPassword.Text;

//Validation
if (string.IsNullOrEmpty(Filename))
{
MessageBox.Show("Please Load your Dictionary File");
}
else if (!Filename.Contains("\\"))
{
MessageBox.Show("Please Enter UNC path");
goto Finish;
}


//Test cnnectin


config Config = new config();
Config.testConnection(un, pw, Filename);

Finish: ;
}


Has this ever happened to anyone else? i really dont see why this is happening. the wrong datapath means wrong connection string..

I'm totally new to C# ive been converted from VB
 
Never mind i got it.

For other newbies that convert from other languages the literal "\" is the escape key

to bypass use the @ in the beginning of the string.
The compiler will bypass it
 
Back
Top