Skip to content

Instantly share code, notes, and snippets.

@andreasbotsikas
Last active December 24, 2015 20:39
Show Gist options
  • Save andreasbotsikas/6859274 to your computer and use it in GitHub Desktop.
Save andreasbotsikas/6859274 to your computer and use it in GitHub Desktop.
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