Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:07:14+00:00 2026-05-26T08:07:14+00:00

Update: I added the missing two variables to the repo code blush Sincere appologies

  • 0

Update:

I added the missing two variables to the repo code blush Sincere appologies about that – I was rushing out to pick up the kids and missed it when i quickly reviewed the post.


When i call the .NET framework’s MakeRelativeUri(…) method and the pass in a Uri which contains a file path .. and the file path has spaces in it .. then there’s a great disturbance in the Force, as if millions of voices suddenly cried out in terror, and were suddenly silenced.

Here’s my repo code. Appologies for this being an MSTest repo and not something a bit nicer like NUnit or XUnit.

[TestMethod]
public void SadPanda()
{
    // Arrange.
    var outputPath =
        @"C:\Users\AAAAAAA.BBBBB\Documents\Visual Studio 2010\Projects\XWing\Code\CCCCCCCCCCC.XWing.Application.Web\content\shared\css\___sa.bundle.#.css";

    var sourcePath =
        @"C:\Users\AAAAAAA.BBBBB\Documents\Visual Studio 2010\Projects\XWing\Code\CCCCCCCCCCC.XWing.Application.Web\content\shared\css\home.css";
    var sourcePathJussy =
        @"C:\Projects\XWing\Code\CCCCCCCCCCC.XWing.Application.Web\content\shared\css\home.css";

    // Added missing 2x vars *blush*    
    var sourceUri = new Uri(Path.GetDirectoryName(sourcePath) + "/", UriKind.Absolute);
    var outputUri = new Uri(Path.GetDirectoryName(outputPath) + "/", UriKind.Absolute);

    var relativePath = "../images/home-feature-bg.png";
    var resolvedSourcePath = new Uri(sourceUri + relativePath, true);

    // Act. 
    var resolvedOutput = outputUri.MakeRelativeUri(resolvedSourcePath);     

    // Assert.
    Assert.IsTrue(resolvedOutput.Contains("XWing")); // :~(
}

Now if you look at the output it is something evil with the real path of the location, etc.

Now if we remove the SPACES from the paths, it now works 🙂

[TestMethod]
public void DoubleRaindbowUnicorns()
{
    // Arrange.
    var outputPath =
        @"C:\Users\AAAAAAA.BBBBB\Documents\Visual Studio 2010\Projects\XWing\Code\CCCCCCCCCCC.XWing.Application.Web\content\shared\css\___sa.bundle.#.css";

    var sourcePath =
        @"C:\Users\AAAAAAA.BBBBB\Documents\Visual Studio 2010\Projects\XWing\Code\CCCCCCCCCCC.XWing.Application.Web\content\shared\css\home.css";
    var sourcePathJussy =
        @"C:\Projects\XWing\Code\CCCCCCCCCCC.XWing.Application.Web\content\shared\css\home.css";

    outputPath = outputPath.Replace(" ", "-");
    sourcePath = sourcePath.Replace(" ", "-");

    // Added missing 2x vars *blush*
    var sourceUri = new Uri(Path.GetDirectoryName(sourcePath) + "/", UriKind.Absolute);
    var outputUri = new Uri(Path.GetDirectoryName(outputPath) + "/", UriKind.Absolute);

    var relativePath = "../images/home-feature-bg.png";
    var resolvedSourcePath = new Uri(sourceUri + relativePath, true);

    // Act. 
    var resolvedOutput = outputUri.MakeRelativeUri(resolvedSourcePath);     

    // Assert.
    Assert.IsFalse(resolvedOutput.Contains("XWing")); // Here yee! Woot, say I!
}

the output of this image resource is ../images/home-feature-bg.png (which by fluke is the same as it’s source path) .. and not the really long evil string.

Yes / no ?

Update 2:

Renamed the subject (to better reflect the answer).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:07:15+00:00Added an answer on May 26, 2026 at 8:07 am

    You need to use the System.IO.Path.Combine() function. What’s happening here is you are using a URI class which cannot contain spaces, which would require the %20 if it were a path for HTML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an Ajax update panel and have recently added ASP.NET tracing code to
There're files/folders that were deleted and then re-added to the repository. svn update >
I have added two update panels to my page. I'm trying to update the
I have a model that for edit/update actions only is logically split into two
EDIT: Modified title and added update. UPDATE : We no longer believe this is
I added a counter cache but can't get it to update. But I can
NOTE: I added my new solution at the UPDATE answer below. I try to
We've noticed that when checking in updates, our .DFM files have added ExplicitWidth and
In my CMS I've added this code <div><?php include(my_contact_form.php) ?></div> which updates to a
I'm using subversion so that I can have two checkouts, one for testing to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.