c# - Directory.GetFiles alters string path -
using system.io, tried following code:
string[] files = directory.getfiles("\\folder\\folder_2\\folder_3"); and got following exception:
"system.io.directorynotfoundexception - not possible locate part of path 'c:\folder\folder_2\folder_3)' "
i don't know why "c:\" added original string, , can't seem keep method doing so. doing wrong?
any appreciated.
you need escape each of beginning backslashes in path, escaped single slash. use either correct escaping:
string[] files = directory.getfiles("\\\\folder\\folder_2\\folder_3"); or can use verbatim string literal:
string[] files = directory.getfiles(@"\\folder\folder_2\folder_3"); full explanation found in msdn documentation
Comments
Post a Comment