Hi indradeo,
Follow the below steps.
1. Under Solution Explorer Right-click on project and select Add Reference.
2. Select the tab COM from the pop-up Window.
3. Under Component Name, select Windows Script Host Object Model Click on OK.
Then use below code to read the shortcut file from the original folder.
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string filePath = @"C:\Users\Dharmendra\Desktop\test.lnk";
if (System.IO.File.Exists(filePath))
{
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
IWshRuntimeLibrary.IWshShortcut link = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
Response.Write(System.IO.File.ReadAllText(link.TargetPath));
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim filePath As String = "C:\Users\Dharmendra\Desktop\test.lnk"
If System.IO.File.Exists(filePath) Then
Dim shell As IWshRuntimeLibrary.WshShell = New IWshRuntimeLibrary.WshShell()
Dim link As IWshRuntimeLibrary.IWshShortcut = CType(shell.CreateShortcut(filePath), IWshRuntimeLibrary.IWshShortcut)
Response.Write(System.IO.File.ReadAllText(link.TargetPath))
End If
End Sub
Output
Welcome to ASPSnippets.