GetPathRoot doesn’t seem to support UNC paths. The result from the code below is simply trimming off file.txt
string root = Path.GetPathRoot("\\servername.pvt\sub dir\file.txt");
What is a good workaround?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The return value is correct. The root is the share, and not the server! For example:
This returns
@"\\servername.pvt\sharename". The server name plus the share name constitutes the path root.