urlcreatefrompath (shlwapi)
Last changed: -65.219.124.65

.
Summary
Converts a Windows file/path to a URL

C# Signature:

[DllImport("shlwapi.dll", CharSet=CharSet.Auto)]

static extern int UrlCreateFromPath(

    [In]     string path,
    [Out]    StringBuilder url,
    [In,Out] ref uint urlLength,
    [In]     object reserved

);

VB Signature:

Declare Function UrlCreateFromPath Lib "shlwapi.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

        [STAThread]
        static void Main(string[] args)
        {
            Console.Write(@"Enter filename: ");
            string filename = Console.ReadLine();
            Console.WriteLine(UrlFromPath(filename));

            Console.Read();

        }

        private static string UrlFromPath(string filepath)
        {
            uint urlLength = 200;
            StringBuilder url = new StringBuilder();
            UrlCreateFromPath(filepath,url,ref urlLength,null);
            return url.ToString();
        }

Documentation