I am trying to get disk cluster size in C #. All I found is talking about using "GetFreeDiskSpace", but I can't get it to work. Looks like I'm missing out on usage or something like that.
When I Google The name 'GetDiskFreeSpace' does not exist in the current context , it causes everything except this specific error. If I do an exact search for a phrase, Google says that nothing was found, and then displays the results of an inaccurate phrase search.
I'm trying to determine where GetFreeDiskSpace comes GetFreeDiskSpace , and not how to fix the message The name 'UnknownKeyWord' does not exist in the current context .
I need to get the actual cluster size on the disk, but I can not determine the size on the disk, but I can fill the ComboBox.
NOTE. I am using VS 2010.
Here is what I have:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Threading; using System.Diagnostics; using System.Globalization; using System.Management; using System.Runtime.InteropServices;
I also have the following:
// Pinvoke for API function [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)]
Code (which is not finished ... I need to parse the information from GetFreeDiskSpace). I need to get the cluster size:
private void btnRefreshDrives_Click(object sender, EventArgs e) { DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { if (d.IsReady) { strDriveInfo = d.Name + " " + d.VolumeLabel; strCurrentFS = d.DriveFormat; strDriveLetter = d.Name;
c # pinvoke
Tornado726
source share