Last active
December 24, 2015 20:39
-
-
Save andreasbotsikas/6859274 to your computer and use it in GitHub Desktop.
A workaround to delete long file names from
http://blogs.msdn.com/b/bclteam/archive/2007/03/26/long-paths-in-net-part-2-of-3-long-path-workarounds-kim-hamilton.aspx
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
using System; | |
using System.Runtime.InteropServices; | |
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
internal static extern bool DeleteFile(string lpFileName); | |
// This code snippet is provided under the Microsoft Permissive License. | |
public static void Delete(string fileName) { | |
// call it with a file name prefixed by \\?\: | |
string formattedName = @"\\?\" + fileName; | |
DeleteFile(formattedName); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment