I am trying to retrieve the value of my readyboost cache I wrote the following code but it says the value does not exist
System.Diagnostics.PerformanceCounterCategory pc;
pc = new System.Diagnostics.PerformanceCounterCategory("ReadyBoost Cache");
pc.GetCounters("Bytes cached");
MessageBox.Show(Convert.ToString(pc));
Spelling is correct, I can see the object following this code
http://msdn.microsoft.com/en-us/library/2fh4x1xb(v=vs.71).aspx
Th开发者_C百科anks in advance
the parameter of GetCounters should be the instance name of the performance Counter. change your code as follows:
System.Diagnostics.PerformanceCounterCategory pc;
pc = new System.Diagnostics.PerformanceCounterCategory("ReadyBoost Cache");
foreach (PerformanceCounter counter in pc.GetCounters())
{
if (counter.CounterName == "Bytes cached")
{
//to do
}
}
精彩评论