Microsoft.Protocols.TestSuites.MS_COPYS.TestSuiteBase.GenerateInvalidFolderPathForFileUrl C# (CSharp) Method

GenerateInvalidFolderPathForFileUrl() protected method

A method used to generate invalid file URL by confusing the folder path. The method will confuse the path part which is nearest to the file name part.
protected GenerateInvalidFolderPathForFileUrl ( string originalFilePath ) : string
originalFilePath string A parameter represents the original file path.
return string
        protected string GenerateInvalidFolderPathForFileUrl(string originalFilePath)
        {
            string fileName = FileUrlHelper.ValidateFileUrl(originalFilePath);
            string directoryName = Path.GetDirectoryName(originalFilePath);

            // Append a guid value to ensure the folder name is not a valid folder.
            string invalidDirectoryName = directoryName + Guid.NewGuid().ToString("N");
            string invalidFileUrl = Path.Combine(invalidDirectoryName, fileName);

            // Work around for local path format mapping to URL path format.
            invalidFileUrl = invalidFileUrl.Replace(@"\", @"/");
            invalidFileUrl = invalidFileUrl.Replace(@":/", @"://");
            return invalidFileUrl;
        }