There are Internet Shortcuts, that you can download and when you click on them, your browser opens the link, is there any way to read the Url from the file, using c#?
C# just says the file doesn't exist, for example when I do File.Exists() and in brackets the correct directory, the outcome is always false.
If you can see the shortcut in Windows File Explorer but you're getting false from
File.Exists()then you're almost certainly using the wrong filename.In File Explorer the file extension for Internet Shortcuts (
*.url) and Shortcuts (*.lnk) are explicitly hidden, regardless of your settings. To get the full path of the file you can select it in File Explorer and then use theCopy Pathoption in theHomeribbon. This will give you the full path and filename of the file regardless of settings or other things that manipulate the name.As for extracting the URL from an Internet Shortcut (
*.url) file... they're simple INI files. You can read the contents of the file as a simple text file and look for the line startingURL=. Trim the start of the line and you have your URL.For example, here's the content of an Internet Shortcut file for Stack Overflow I just created on my desktop:
Extracting the URL from that is fairly simple: