Hi
getting error - Unrecognized excape sequence
attachment.FileName = "@10.0.1.10\SAP_Attachments\O_204673_20250314_205951");
Thanks
Hi
getting error - Unrecognized excape sequence
attachment.FileName = "@10.0.1.10\SAP_Attachments\O_204673_20250314_205951");
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prasad RaveendranPosted Mar 16, 2025, 5:46 AM
Solution
You need to use double backslashes (
\\) or a verbatim string literal (@prefix) to correctly format the file path.Option 1: Escape Backslashes
Option 2: Use a Verbatim String Literal
Note
Your original string starts with
@, which is incorrect syntax. If you meant to use a verbatim string, you should write:This correctly represents a UNC (Universal Naming Convention) path for a network share.
Jignesh KumarPosted Mar 15, 2025, 9:45 AM
Hello Ramco,
You need to add a Verbatim String (
@before the string), just check on this it should resolve your issueSophia CarterPosted Mar 15, 2025, 8:35 AM
It seems like the error you are encountering is related to an unrecognized escape sequence in C# code. In the provided code snippet:
The issue lies with the backslashes used in the file path. In C# strings, backslashes are used to escape characters, meaning they are interpreted as special characters. If you want to include a backslash as a literal character in a string, you need to escape it by using another backslash before it.
To resolve the error, you can correct the file path string by escaping the backslashes properly, like this:
By doubling the backslashes, you are telling the C# compiler to treat them as literal backslashes in the string. This adjustment should resolve the "Unrecognized escape sequence" error you are facing.
If you encounter any further issues or have additional questions, feel free to let me know!