12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Utilities;
- namespace SMBLibrary.Server
- {
- public class ServerPathUtils
- {
-
-
- public static string GetRelativeServerPath(string path)
- {
- if (path.StartsWith(@"\\"))
- {
- int index = path.IndexOf('\\', 2);
- if (index > 0)
- {
- return path.Substring(index);
- }
- else
- {
- return String.Empty;
- }
- }
- return path;
- }
-
-
- public static string GetRelativeSharePath(string path)
- {
- string relativePath = GetRelativeServerPath(path);
- int index = relativePath.IndexOf('\\', 1);
- if (index > 0)
- {
- return path.Substring(index);
- }
- else
- {
- return @"\";
- }
- }
- public static string GetShareName(string path)
- {
- string relativePath = GetRelativeServerPath(path);
- if (relativePath.StartsWith(@"\"))
- {
- relativePath = relativePath.Substring(1);
- }
- int indexOfSeparator = relativePath.IndexOf(@"\");
- if (indexOfSeparator >= 0)
- {
- relativePath = relativePath.Substring(0, indexOfSeparator);
- }
- return relativePath;
- }
- }
- }
|