Is there a way to flush the DNS cache from a C# WPF app? The application would be running on either XP, Vista, or Windows 7.
You can use a function from Microsoft's "dnsapi.dll". This will allow you to do this completely programmatically:
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();
}
I have tested this and it works great.