@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The DeleteFile API !!!!C# Signature: [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool DeleteFile(string lpFileName); [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool DeleteFileA([MarshalAs(UnmanagedType.LPStr)]string lpFileName); [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool DeleteFileW([MarshalAs(UnmanagedType.LPWStr)]string lpFileName); !!!!User-Defined Types: None. !!!!Notes: Use DeleteFileW for Unicode names and DeleteFileA for ANSI names. In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path or "\\?\UNC\" for fileshares on server, respectively. e.g. "\\?\D:\very long path" or "\\?\UNC\server\share" !!!!Tips & Tricks: Please add some! !!!!Sample Code: String filePath = @"C:\Data\MyFile.txt"; bool deleted = DeleteFileW(filePath); if (!deleted) { int lastError = Marshal.GetLastWin32Error(); Console.WriteLine("Failed to delete '{1}': error={0}", lastError, filePath); } !!!!Alternative Managed API: System.IO.File: public static void Delete(string path); Documentation: DeleteFile@msdn on MSDN
Edit kernel32.deletefile
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.