Esempio n. 1
0
        public string GetPhysicalPath(PhysicalServer site, string path, bool forceLocalPath)
        {
            var standardizedPath = path;

            if (!IsUncPath(standardizedPath))
            {
                standardizedPath = @"\\{0}\{1}".FormatWith(site.Name, standardizedPath);
            }

            if (path.StartsWith("~"))
            {
                standardizedPath = standardizedPath.Replace(@"~\", "");
            }

            standardizedPath = standardizedPath.Replace(':', '$');

            if (site.IsLocal || forceLocalPath)
            {
                var serviceLocation = standardizedPath;
                var regex           = new Regex(@"(?<front>[\\\\]?.+?)\\(?<shareName>[A-Za-z0-9\+\.\~\!\@\#\$\%\^\&\(\)_\-'\{\}\s-[\r\n\f]]+)\\?(?<rest>.*)", RegexOptions.IgnoreCase & RegexOptions.Multiline & RegexOptions.IgnorePatternWhitespace);
                var shareMatch      = regex.Match(standardizedPath);
                if (shareMatch.Success)
                {
                    var shareName = shareMatch.Groups["shareName"].Value;
                    serviceLocation = Win32Share.GetLocalPathForShare(site.Name, shareName);
                }
                var rest = shareMatch.Groups["rest"].Value;
                standardizedPath = System.IO.Path.Combine(serviceLocation, rest);
            }

            return(standardizedPath);
        }
Esempio n. 2
0
        public string ConvertUncShareToLocalPath(PhysicalServer site, string path)
        {
            var serviceLocation = path;
            var regex           = new Regex(@"(?<front>[\\\\]?.+?)\\(?<shareName>[A-Za-z0-9\+\.\~\!\@\#\$\%\^\&\(\)_\-'\{\}\s-[\r\n\f]]+)\\?(?<rest>.*)", RegexOptions.IgnoreCase & RegexOptions.Multiline & RegexOptions.IgnorePatternWhitespace);
            var shareMatch      = regex.Match(path);

            if (shareMatch.Success)
            {
                var shareName = shareMatch.Groups["shareName"].Value;
                serviceLocation = Win32Share.GetLocalPathForShare(site.Name, shareName);
            }
            var rest = shareMatch.Groups["rest"].Value;

            return(System.IO.Path.Combine(serviceLocation, rest));
        }