N.R.S.Sowrabh
N.R.S.Sowrabh

Reputation: 725

How can I find the target of a symbolic link using VB.NET?

How can I find if a given file is a symbolic link? And once I know that it is, how can I get the target its pointing to? I'm using VB.NET in Visual Studio 2010.

Upvotes: 1

Views: 3184

Answers (3)

satyadeepk
satyadeepk

Reputation: 351

http://www.codeproject.com/KB/vista/ReparsePointID.aspx Go through this, I tried it and it works. It is written in C# and can be easily convertded into VB

Upvotes: 2

tiago2014
tiago2014

Reputation: 3461

Link: How do I get information about the target of a symbolic link? http://blogs.msdn.com/b/oldnewthing/archive/2010/02/12/9962359.aspx

...

Okay, great, so now I know I have a symbolic link, but what if I want information about the link target? For example, I want to know the size of the link target, its last-modified time, and its name.

To do this, you open the symbolic link. The I/O manager dereferences the symbolic link and gives you a handle to the link destination. You can then call functions like GetFileSize, GetFileInformationByHandleEx, or GetFinalPathNameByHandle to obtain information about the symbolic link target.

...

Upvotes: 0

Ken White
Ken White

Reputation: 125671

You use the IShellLink interface.

An example of using it in VB.Net is here. While this example shows creating shortcuts, you can use it to see how to use IShellLink from within VB.Net code.

Upvotes: 0

Related Questions