Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 886017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:00:12+00:00 2026-05-15T13:00:12+00:00

I have written a small WPF widget using C# that displays the current CPU

  • 0

I have written a small WPF widget using C# that displays the current CPU activity, RAM used and disk activity as three small percentage type bars. I have used the following PerformanceCounters for this: (diskCounter PerformanceCounter returns current total disk activity in bytes per second)

private void InitialisePerformanceCounters()
{
    cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
    totalRam = (int)(new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory / 1024 / 1024);
    ramCounter = new PerformanceCounter("Memory", "Available MBytes");
    diskCounter = new PerformanceCounter("PhysicalDisk", "Disk Bytes/sec", "_Total", true);
}

The problem is that although I have discovered how to get the total available RAM to calculate a used percentage from, I cannot find out how to read the disk’s ‘theoretical’ maximum data transfer rate. I need this to calculate the percentage of disk transfer rate used.
Any help would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:00:12+00:00Added an answer on May 15, 2026 at 1:00 pm

    The only way to do this would be to test it yourself. You could do something like this at the beginning of your application:

    byte[] data = new byte[1024];
    
    string path = System.IO.Path.GetTempFileName();
    
    int bytesPerSecond = 0;
    
    using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create))
    {
        System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
    
        watch.Start();
    
        for (int i = 0; i < 1024; i++) fs.Write(data, 0, data.Length);
    
        fs.Flush();
    
        watch.Stop();
    
        bytesPerSecond = (int)((data.Length * 1024) / watch.Elapsed.TotalSeconds);
    }
    
    System.IO.File.Delete(path);
    

    This does, however, assume that the Temp directory is on the disk in question. If not, you’ll have to create a path on the disk you want to measure. Note that this is measuring write speed, not read speed.

    This is somewhat contrived since 1MB is not much data to write, but you could try it with a larger amount of data; the concept is the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a small app, that has a Activity to control and display
I have a small report/logging application written in C#.NET 4.0 and WPF that I
I have written a small android app that grabs some data and displays it
I have written a small plugin that displays tweets. following is the code that
I have written a small chat app that uses mysql + php to facilitate
I have written a small app that puts my bluetooth in discoverable mode for
I have written a small makefile for a few simple C programs that compiles
I have written a small program using Borland's C++ builder, and along the way,
I have written a small XML validator, that takes in an XML file and
I have written a small application which will be used in my work environment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.