Created
November 7, 2013 17:47
-
-
Save skarllot/7358789 to your computer and use it in GitHub Desktop.
Get symbolic link target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Shiva (http://stackoverflow.com/a/487404/1028452) | |
static void Main(string[] args) | |
{ | |
using (FileStream fs = File.OpenRead(@"D:\temp\case\mytest.txt")) | |
{ | |
StringBuilder path = new StringBuilder(512); | |
GetFinalPathNameByHandle(fs.SafeFileHandle.DangerousGetHandle(), path, path.Capacity, 0); | |
Console.WriteLine(path.ToString()); | |
} | |
} | |
[DllImport("kernel32.dll", SetLastError = true)] | |
static extern int GetFinalPathNameByHandle(IntPtr handle, [In, Out] StringBuilder path, int bufLen, int flags); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment