Python raw string "r" flag equivalent in C#

12,743

In C#, you can either use double slashes (like in Java), or you can use @ instead of r to create a verbatim string literal:

string IE_DRIVER_PATH = @"C:\software\selenium\temp\drivers\64";
Share:
12,743
Naveen Kumar R B
Author by

Naveen Kumar R B

I am working in the software testing field. Working in functional, automation and performance test areas. Working on tools: Selenium, Selenide, Java, Python, Jmeter, LoadRunner. My presentation on TCP/IP: https://www.slideshare.net/NaveenKumarRB/tcpip-introduction-77072823 You can connect to me on LinkedIn: https://www.linkedin.com/in/rbnaveen558/

Updated on September 16, 2022

Comments

  • Naveen Kumar R B
    Naveen Kumar R B over 1 year

    I am trying to give the file path in C# which contains special/escape characters. I am new to C#. please help me in defining the file path as raw string literals.

    Following is path (\t has spl meaning):

    IE_DRIVER_PATH = "C:\software\selenium\temp\drivers\64"

    In python we use it as follows (using r - to treat it as raw stiring):

    IE_DRIVER_PATH = r"C:\software\selenium\temp\drivers\64"

    similarly, In java, we use double slashes.

    please help me in defining the same in C#. As of now, I am getting the error which says that file does not exist, though the file is present in the folder.