I tried the answers above, unfortunately it was not simple as it seems...
The first answer, using the management object looks like the correct way of doing so but unfortunately the "Format" method is not supported in windows xp.
The second and the third answers are working but require the user to confirm the operation.
In order to do that without any intervention from the user I used the second option with redirecting the input and output streams of the process. When I redirecting only the input stream the process failed.
The following is an example:
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady && (d.DriveType == DriveType.Removable))
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "format";
startInfo.Arguments = "/fs:FAT /v:MyVolume /q " + d.Name.Remove(2);
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
Process p = Process.Start(startInfo);
StreamWriter processInputStream = p.StandardInput;
processInputStream.Write("\r\n");
p.WaitForExit();
}
}