System.Configuration.UrlPath.ConvertFileNameToUrl C# (CSharp) Метод

ConvertFileNameToUrl() статический приватный Метод

static private ConvertFileNameToUrl ( string fileName ) : string
fileName string
Результат string
        internal static string ConvertFileNameToUrl(string fileName) {
            string prefix;

            if (IsAbsoluteLocalPhysicalPath(fileName)) {
                prefix = FILE_URL_LOCAL;
            }
            else if (IsAbsoluteUNCPhysicalPath(fileName)) {
                prefix = FILE_URL_UNC;
            }
            else {
                // We should never get here, but if we do we are likely to have
                // serious security problems, so throw an exception rather than simply 
                // asserting.
                throw ExceptionUtil.ParameterInvalid("filename");
            }

            string newFileName = prefix + fileName.Replace('\\', '/');
            return newFileName;
        }
    }

Usage Example

Пример #1
0
        public override void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
        {
            // Get the stream name as a URL
            string url;
            bool   isFile = IsFile(configRecord.StreamName);

            if (isFile)
            {
                url = UrlPath.ConvertFileNameToUrl(configRecord.StreamName);
            }
            else
            {
                url = configRecord.StreamName;
            }

            Evidence evidence = new Evidence();

            // Add Url evidence, which is simply the URL.
            evidence.AddHostEvidence(new Url(url));

            // Add Zone evidence - My Computer, Intranet, Internet, etc.
            evidence.AddHostEvidence(Zone.CreateFromUrl(url));

            // Add Site evidence if the url is http.
            if (!isFile)
            {
                evidence.AddHostEvidence(Site.CreateFromUrl(url));
            }

            // Get the resulting permission set.
            permissionSet = SecurityManager.GetStandardSandbox(evidence);

            // Client host is always ready to return permissions.
            isHostReady = true;
        }
All Usage Examples Of System.Configuration.UrlPath::ConvertFileNameToUrl