{"id":300,"date":"2025-03-15T11:49:17","date_gmt":"2025-03-15T03:49:17","guid":{"rendered":"https:\/\/yizero.top\/?p=300"},"modified":"2025-07-17T10:07:06","modified_gmt":"2025-07-17T02:07:06","slug":"c-practice-project-dns-cache-cleaner-tool","status":"publish","type":"post","link":"https:\/\/yizero.top\/index.php\/2025\/03\/15\/c-practice-project-dns-cache-cleaner-tool\/","title":{"rendered":"[C#\u7ec3\u624b\u9879\u76ee] &#8211; DNS\u7f13\u5b58\u6e05\u7406\u5de5\u5177"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u7b80\u4ecb\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u4e00\u952e\u6e05\u7406\u7535\u8111DNS\u7f13\u5b58\u7684\u5c0f\u5de5\u5177\uff0c\u89e3\u51b3\u7535\u8111\u56e0\u4e3aDNS\u95ee\u9898\u5f15\u8d77\u7684\u7f51\u7edc\u95ee\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u524d\u8a00\uff1a<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">C#\u7684\u7684\u7b2c\u4e00\u4e2a\u7ec3\u624b\u9879\u76ee\uff0c\u4e3b\u8981\u662f\u7ec3\u4e60\u4e00\u4e0b\u57fa\u672c\u529f\uff0c\u63d0\u4f9b\u6e90\u4ee3\u7801\u548c\u7f16\u8bd1\u597d\u7684.exe\u7a0b\u5e8f\uff0c\u4f9b\u5404\u4f4d\u4e0b\u8f7d\u7684\u7f16\u8bd1\uff0c\u65b0\u624b\u4e0a\u8def\u5927\u4f6c\u52ff\u55b7\u3002\u3002\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u754c\u9762\u9884\u89c8\uff1a<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/yizero.top\/wp-content\/uploads\/2025\/03\/Snipaste_2025-03-15_11-33-26.jpg'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"896\" data-original=\"https:\/\/yizero.top\/wp-content\/uploads\/2025\/03\/Snipaste_2025-03-15_11-33-26.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-307\"  sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><\/div><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u6e90\u4ee3\u7801\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Diagnostics;\nusing System.Threading;\n\nnamespace DNS_cache_cleaner_tool\n{\n    \n    class Program\n    {\n        \n        static void Main(string&#91;] args)\n        {\n            \n\n            Console.Title = \"DNS Cache Cleaner Tool C#\";\n\n            Process p = new Process();\n            \/\/\u8bbe\u7f6e\u8981\u542f\u52a8\u7684\u5e94\u7528\u7a0b\u5e8f\n            p.StartInfo.FileName = \"cmd.exe\";\n            \/\/\u662f\u5426\u4f7f\u7528\u64cd\u4f5c\u7cfb\u7edfshell\u542f\u52a8\n            p.StartInfo.UseShellExecute = false;\n            \/\/ \u63a5\u53d7\u6765\u81ea\u8c03\u7528\u7a0b\u5e8f\u7684\u8f93\u5165\u4fe1\u606f\n            p.StartInfo.RedirectStandardInput = true;\n            \/\/\u8f93\u51fa\u4fe1\u606f\n            p.StartInfo.RedirectStandardOutput = true;\n            \/\/\u8f93\u51fa\u9519\u8bef\n            p.StartInfo.RedirectStandardError = true;\n            \/\/\u4e0d\u663e\u793a\u7a0b\u5e8f\u7a97\u53e3\n            p.StartInfo.CreateNoWindow = true;\n            \/\/\u542f\u52a8\u7a0b\u5e8f\n            p.Start();\n\n            Console.WriteLine(\"\u662f\u5426\u6e05\u7406DNS\u7f13\u5b58(y\/n)\uff1a\");\n\n            string User_txt = Console.ReadLine();\n            \/\/Console.WriteLine(\"\u7528\u6237\u8f93\u5165\uff1a\" + User_txt);\n\n            if (User_txt == \"y\")\n            {\n                \/\/Console.WriteLine(\"\u5f00\u59cb\u6e05\u7406DNS\u7f13\u5b58...\");\n                \/\/\u58f0\u660e\u4e00\u4e2a\u540d\u4e3astrInput\u7684string\u53d8\u91cf\u5e76\u7ed9\u5176\u8d4b\u503c\n                string strInput = \"ipconfig\/flushdns\";\n                \/\/\u5411cmd\u7a97\u53e3\u53d1\u9001\u8f93\u5165\u4fe1\u606f\n                p.StandardInput.WriteLine(strInput + \"&amp;exit\");\n                p.StandardInput.AutoFlush = true;\n                \/\/\u83b7\u53d6\u8f93\u51fa\u4fe1\u606f\n                string strOuput = p.StandardOutput.ReadToEnd();\n                \/\/\u7b49\u5f85\u7a0b\u5e8f\u6267\u884c\u5b8c\u9000\u51fa\u8fdb\u7a0b\n                p.WaitForExit();\n                p.Close();\n                \/\/\u8f93\u51fa\u63a7\u5236\u53f0\u8fd4\u56de\u4fe1\u606f\n                \/\/Console.WriteLine(strOuput);\n                \/\/\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3aPD\u7684bool\u7c7b\u578b\u53d8\u91cf\u5e76\u8d4b\u503c\uff0cbool\u7c7b\u578b\u5b58\u50a8true\u6216false\n                bool PD = strOuput.Contains(\"\u5df2\u6210\u529f\u5237\u65b0 DNS \u89e3\u6790\u7f13\u5b58\u3002\");\n\n                if (PD == true)\n                {\n                    Console.WriteLine(\"\u6e05\u7406\u5b8c\u6210\uff01\");\n                    Console.WriteLine(\"\u7a0b\u5e8f\u5c06\u57282\u79d2\u540e\u9000\u51fa...\");\n                    Thread.Sleep(2000);\n                    \/\/Console.ReadKey();\n                }\n                else\n                {\n                    Console.WriteLine(\"\u6e05\u7406\u5931\u8d25\uff01\");\n                    Console.WriteLine(\"\u7a0b\u5e8f\u5c06\u57282\u79d2\u540e\u9000\u51fa...\");\n                    Thread.Sleep(2000);\n                    \/\/Console.ReadKey();\n                }\n            }\n            else\n            {\n                Console.WriteLine(\"\u7a0b\u5e8f\u5c06\u57282\u79d2\u540e\u9000\u51fa...\");\n                Thread.Sleep(2000);\n            }\n            \n            \n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e0b\u8f7d\u533a\uff1a<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u7c7b\u578b<\/td><td>\u5730\u5740<\/td><td>\u63d0\u53d6\u7801<\/td><\/tr><tr><td>.exe<\/td><td><a href=\"https:\/\/wankesixiang.lanzoub.com\/i8naF2qngguj\" target=\"_blank\" rel=\"noopener\">https:\/\/wankesixiang.lanzoub.com\/i8naF2qngguj<\/a><\/td><td>aw6k<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb\uff1a \u4e00\u6b3e\u8f7b\u91cf\u7ea7\u4e00\u952e\u6e05\u7406\u7535\u8111DNS\u7f13\u5b58\u7684\u5c0f\u5de5\u5177\uff0c\u89e3\u51b3\u7535\u8111\u56e0\u4e3aDNS\u95ee\u9898\u5f15\u8d77\u7684\u7f51\u7edc\u95ee\u9898\u3002 \u524d\u8a00\uff1a C#\u7684\u7684\u7b2c\u4e00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,4,5],"tags":[35,33,15,8,10,16],"class_list":["post-300","post","type-post","status-publish","format-standard","hentry","category-c_sharp","category-essay","category-software","tag-c","tag-windows","tag-15","tag-8","tag-10","tag-16"],"_links":{"self":[{"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/posts\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":10,"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/posts\/300\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yizero.top\/index.php\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}