3
Answers

How to remove the extra '\'s from a file given by the System.IO.Directory.GetFiles()

Ask a question
Brian

Brian

13y
1.8k
1
Hello,

Forgive me if this is a simple question, I am new to C#. I am enumerating files on a shared network drive and the files that are returned with the System.IO.Directory.GetFiles() are in the format of '\\\\shared folder\\directory\\file'. How can I remove the extra '\'s? I need to use the file and its full path inside of a sql select statement but without the extra '\'s. I tried file.Replace(@"\\",@"\") but it did not work.

Thanks in advance

Answers (3)