开发者

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

开发者 https://www.devze.com 2023-02-02 12:46 出处:网络
How can I find if a 开发者_JAVA百科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.http://www.codeproject.c

How can I find if a 开发者_JAVA百科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.


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


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.


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.

...

0

精彩评论

暂无评论...
验证码 换一张
取 消