private void Form1_Load(object sender, EventArgs e)
        {
            string file = Application.ExecutablePath;
            file=file.Replace('\\','\');
                         string  test = "\\";
            int start;
            start = file.Length;
                     
            int lPos;
            lPos = file.IndexOf(test, start);


        }

First Question

I want to ask dat y in variable file \\ are coming.how can I replace \\ by \
If I write the Foll. Statement-

file=file.Replace('n','a');

Everything is fine.n is replaced by a

But If I write statement-

file=file.Replace('\\','\');

Errors are there-
1)Too many characters in character literal
2)Newline in constant
3) ) expected
4); expected

Second Question
I want to find the position of \ in file from last.

because \ treats the next character as litteral/escape so \\ actually would be \ in reality

'\\' is not a character litteral. A character is always one character symbol enclosed in single quotes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.