C# 刷新DNS缓存
方法一:
using System.Runtime.InteropServices;
[DllImport("dnsapi.dll",EntryPoint="DnsFlushResolverCache")]
private static extern UInt32 DnsFlushResolverCache ();
public static void FlushMyCache() //This can be named whatever name you want and is the function you will call
{
UInt32 result = DnsFlushResolverCache();
}
方法二:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C ipconfig /flushdns";
process.StartInfo = startInfo;
process.Start();
作者:江宁织造
博客:http://www.cnblogs.com/wgx0428/
博客:http://www.cnblogs.com/wgx0428/