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 6732263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:37:44+00:00 2026-05-26T10:37:44+00:00

I need to parse a URL into an array and was having some difficulties

  • 0

I need to parse a URL into an array and was having some difficulties figuring out how to do it properly. It’s a bit complicated.

So my URL would be something like this:

http://sharepoint/webname/libraryname/subfolder1/subfolder2/subfolder3/documentname

And the results would need to be like so

array0 - http://sharepoint
array1 - webname
array2 - libraryname
array3 - subfolder1/subfolder2/subfolder3 
array4 - documentname

I would appreciate any guidance.

  • 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-26T10:37:44+00:00Added an answer on May 26, 2026 at 10:37 am

    This works for me:

    var uri = new Uri(@"http://sharepoint/webname/libraryname/subfolder1/"
        + "subfolder2/subfolder3/documentname");
    
    var segments =
        uri.Segments
            .Select(s => s.EndsWith("/") ? s.Substring(0, s.Length - 1) : s)
            .ToArray();
    
    var array = new []
    {
        String.Format("{0}://{1}", uri.Scheme, uri.Host),
        segments[1],
        segments[2],
        String.Join("/", segments.Skip(3).Take(segments.Length - 4)),
        segments[segments.Length - 1],
    };
    

    I get this result:

    Parsed Uri Array

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

Sidebar

Related Questions

I need parse through a file and do some processing into it. The file
I need to parse some CSS code like: color: black; font-family:Courier New; background:url('test.png'); color:
I need to parse a URL to get the protocol, host, path, and query
it's my first post here :) I'm having some difficulties with dealing with urls
I am looking for a way to parse url link into following segments without
I want something to turn ?a=5&b=8 part of a URL into a dictionary {
So I need some way of turning given Protocol://URLorIP:Port string into string ip int
I'm using javascript and need to parse out a query argument that is a
My app bounces the user out of the app into safari to do some
I need to parse a URL string like this one: &ad_eurl=http://www.youtube.com/video/4bL4FI1Gz6s&hl=it_IT&iv_logging_level=3&ad_flags=0&endscreen_module=http://s.ytimg.com/yt/swfbin/endscreen-vfl6o3XZn.swf&cid=241&cust_gender=1&avg_rating=4.82280613104 I need 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.