12345678910111213141516171819202122232425 |
- using System.Diagnostics;
- namespace Archives_Center
- {
- public class DeleteFolderWithAdminRights
- {
- public static void DeleteFolder(string folderPath)
- {
- string command = $"/c rmdir /s /q \"{folderPath}\"";
- ProcessStartInfo psi = new ProcessStartInfo
- {
- FileName = "cmd.exe",
- Arguments = command,
- Verb = "runas",
- UseShellExecute = true,
- WindowStyle = ProcessWindowStyle.Hidden
- };
- using (Process p = Process.Start(psi))
- {
- p.WaitForExit();
- }
- }
- }
- }
|