lti2000

Any one can help me with C# code to change Volume Serial of a disk drive.

Thank you in advance



Re: Visual C# General How to change Disk's volume Serial

Friendly Dog

using System;

using System.Collections.Generic;

using System.Text;

using System.Management;

 

namespace WMIDiskSerial

{

class Program

{

static void Main(string[] args)

{

ManagementObject diskObj = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");

diskObj.Get();

Console.WriteLine(diskObj["VolumeSerialNumber"].ToString());

Console.ReadLine();

}

}

}






Re: Visual C# General How to change Disk's volume Serial

Friendly Dog

Oh sorry, you meant "change". I don't know...




Re: Visual C# General How to change Disk's volume Serial

mr_super_genius

You can change the VolumeLabel of a drive by the following example...but i m not sure about volume serial

System.IO.DriveInfo d = new System.IO.DriveInfo("E");

d.VolumeLabel = "NewLabel";