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
Loading
VulpesPosted Sep 6, 2011, 9:55 AM
I thought it was strange that the GetFiles() method didn't seem to be working correctly.
BrianPosted Sep 6, 2011, 9:52 AM
VulpesPosted Sep 2, 2011, 4:18 PM
string s = @"\\\\shared folder\\directory\\file";
s = s.Replace(@"\\", @"\");
Console.WriteLine(s);
output:
\\shared folder\directory\file
Incidentally, are you sure that the strings are 'really' like they look and don't just appear like that in the debugger?
I'd try doing a MessageBox.Show on one of them to make sure.