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); }