I'm trying to create a console uninstaller for my friends, since they use addons for left 4 dead, and I am trying to make this to remove them before they update.. heres the code so far
using System;
using System.IO;
class Test
{
public static void Main()
{
// Specify the directories you want to manipulate.
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui/l4dr_logo.vmt";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3";
string path = @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vmt";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3";
string path = @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3";
try
{
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam/steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam/steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg");
}
// Determine whether the directory exists.
if (!Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles"))
{
// Delete Directory
Directory.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles");
}
// Determine whether the directory exists.
if (!Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts"))
{
// Delete Directory
Directory.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui/l4dr_logo.vmt"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui/l4dr_logo.vmt");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3"))
{
// Delete Directory
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3");
}
// Determine whether the File exists.
if (!File.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3"))
{
// Delete File
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg");
}
// Determine whether the directory exists.
if (!Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles"))
{
// Delete Directory
Directory.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles");
}
// Determine whether the directory exists.
if (!Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts"))
{
// Delete Directory
Directory.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vmt"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vmt");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3");
}
// Determine whether the File exists.
if (!File.Exists(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3"))
{
// Delete File
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3");
}
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles");
Directory.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts");
Directory.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui/l4dr_logo.vmt");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui/l4dr_logo.vmt", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3");
File.Delete(@"C:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\autoexec.cfg", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles");
Directory.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_glow_profiles", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts");
Directory.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\cfg\l4d_scripts", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vmt");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vmt", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\materials\vgui\l4dr_logo.vtf", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\l4d_crashcourse_bg.bik", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\media\StartupVids.txt", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\HUD\TeammatePanel.res", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\resource\UI\L4D360UI\MainMenu.res", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup1.mp3", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup2.mp3", true);
Console.WriteLine("The Delete operation was successful.");
// This will succeed because subdirectories are being deleted.
Console.WriteLine("Uninstallation is in progress", @"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3");
File.Delete(@"E:\Program Files (x86)\Steam\steamapps\common\left 4 dead\left4dead\sound\UI\gamestartup3.mp3", true);
Console.WriteLine("The Delete operation was successful.");
}
catch (Exception e)
{
Console.WriteLine("What's this bullshit? a bug, you may need to retry manually: {0}", e.ToString());
}
finally {}
}
}
now the problem is, it wont let me use 'path' multiple times, and... it says i need an overload 2+ or something for file.delete