public static void ExtractAndDelete(string theserverfolder) { ClientAndServer.ExtractResourcesForBoth(); ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(theserverfolder)); ClientAndServer.DeleteVpks(ClientAndServer.Returnallvpks(theserverfolder)); string resourceData = Resources.delete; // var words = resourceData.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); string[] items = resourceData.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); Parallel.ForEach(items, lines => { string fun = Path.Combine(theserverfolder, lines); FileAttributes attr = 0; if (File.Exists(fun) || Directory.Exists(fun)) { attr = File.GetAttributes(fun); } if (attr.HasFlag(FileAttributes.Directory)) { MiscFunctions.DeleteDir(Path.Combine(theserverfolder, lines)); } else { MiscFunctions.DeleteFile(Path.Combine(theserverfolder, lines)); } }); }
private static void Paralleloneachgame(string sourcesdk2007Installdir, IEnumerable <string> storedlocations, string ocinstalldir) { Parallel.ForEach(storedlocations, game => { if (game == " ") { } else if (game.EndsWith("hl2")) { MiscFunctions.DeleteDir(sourcesdk2007Installdir + "\\hl2"); ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(game), ocinstalldir); NativeMethods.Otherstuff.CreateSymbolicLink(sourcesdk2007Installdir + "\\hl2", game, NativeMethods.Otherstuff.SymbolicLinkFlag.Directory); } else { string gamename = game.Split(Path.DirectorySeparatorChar).Last(); MiscFunctions.DeleteDir(sourcesdk2007Installdir + "\\" + gamename); ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(game), ocinstalldir); NativeMethods.Otherstuff.CreateSymbolicLink(sourcesdk2007Installdir + "\\" + gamename, game, NativeMethods.Otherstuff.SymbolicLinkFlag.Directory); if (gamename.Equals(@"cstrike")) { File.Create(ocinstalldir + "\\mounts\\css"); } else if (gamename.Equals(@"hl1")) { File.Create(ocinstalldir + "\\mounts\\hls"); } else { File.Create(ocinstalldir + "\\mounts\\" + gamename); } } }); }