locked
Does there has the corresponding PathIsURL() API in metro?

    Question

  • In window7, I use PathIsURL() to check a URL which conforms to a valid format.

    However, PathIsURL() is desktop only.

    In metro, which API could be used?

    Thanks.
    Monday, August 27, 2012 11:21 AM

All replies

  • Hi,

    As far as I know, there is no alternative function for PathIsURL API.
    But we can use Uri::Path or Uri::Domain to know if it is URL or file path.
    Please follow these codes.

    	String^ uriToLaunch = L"http://www.bing.com";
    	auto uri = ref new Windows::Foundation::Uri(uriToLaunch);
    	String^ path=uri->Path; // The Path is /
    	
    	String^ uriImage = "ms-appx:///images/SecondaryTileDefault-sdk.png";
    	auto uri2 = ref new Windows::Foundation::Uri(uriImage);
    	String^ weburi=uri2->Domain; // The domain is empty
    	path=uri2->Path;
    


    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, August 28, 2012 9:10 AM
  • Hi Jesse:

    Thank you for your reply.

    After I test these codes, the result seems that it cannot confirm if it's URL by this method.

    My test codes as below:

    String^ uriToLaunch = L"http://127.0.0.1/mm/1.mp3";
    auto uri = ref new Windows::Foundation::Uri(uriToLaunch);
    String^ weburi1=uri->Domain; // The weburi1 is ""
    String^ path=uri->Path; // The path is /mm/1.mp3

    Tuesday, August 28, 2012 10:34 AM
  • Yes, I found that problem. But there is no PathIsURL function in Win8 style app, my solution should be a temporary solution.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, August 30, 2012 6:16 AM
  • if you successfully construct Windows::Foundation::Uri with a string then you know it conforms to the uri syntax rules. failure means otherwise.

    if you provide more information about your scenario it might lead to other solutions that don't require testing to see if the value is a uri.

    Chris

    Tuesday, September 04, 2012 4:12 AM