Function to shrink file path to be more human readable
问题 Is there any function in c# to shink a file path ? Input : "c:\users\Windows\Downloaded Program Files\Folder\Inside\example\file.txt" Output : "c:\users\...\example\file.txt" 回答1: Jeff Atwood posted a solution to this on his blog and here it is : [DllImport("shlwapi.dll", CharSet = CharSet.Auto)] static extern bool PathCompactPathEx([Out] StringBuilder pszOut, string szPath, int cchMax, int dwFlags); static string PathShortener(string path, int length) { StringBuilder sb = new StringBuilder()