I am trying to read the contents of IIS logfiles using C#, but I do not know how to find where they are. The physical location on my PC is C:\inetpub\logs\LogFiles\W3SVC1.
In my software I am using:
string serverName = "localhost";
DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + serverName + "/logs/logfiles/w3svc/1");foreach (DirectoryEntry d in W3SVC.Children)
{
MessageBox.Show(d.Name);
}
But it says the path does not exist. I am also not sure that the foreach will bring back each file within the directory anyway. I think it will bring back each child directory, which is not what I want.
Can anyone point me in the right direction please.