Таким способом я передаю данные в строки, потом сохраняю в txt.
private string DeviceInformation(string stringIn)
{
StringBuilder StringBuilder1 = new StringBuilder(string.Empty);
try
{
ManagementClass ManagementClass1 = new ManagementClass(stringIn);
//Create a ManagementObjectCollection to loop through
ManagementObjectCollection ManagemenobjCol = ManagementClass1.GetInstances();
//Get the properties in the class
PropertyDataCollection properties = ManagementClass1.Properties;
foreach (ManagementObject obj in ManagemenobjCol)
{
foreach (PropertyData property in properties)
{
try
{
if (property.Name == "Name" ||
property.Name == "Description" ||
property.Name == "Size" ||
property.Name == "Status" ||
property.Name == "ProductName" ||
property.Name == "ProductName" ||
property.Name == "ProductName" ||
property.Name == "FreeSpace" ||
property.Name == "ProviderName" ||
property.Name == "InstallDate" ||
property.Name == "Manufacturer" ||
property.Name == "Version" ||
property.Name == "BIOSVersion" ||
property.Name == "DataWidth" ||
property.Name == "ProcessorType" ||
property.Name == "L2CacheSize" ||
property.Name == "L2CacheSpeed" ||
property.Name == "L3CacheSpeed" ||
property.Name == "LastErrorCode" ||
property.Name == "MaxClockSpeed" ||
property.Name == "L2CacheSize" ||
property.Name == "L2CacheSize" ||
property.Name == "PathName" ||
property.Name == "Network" ||
property.Name == "PrinterStatus" )
{
StringBuilder1.AppendLine(EnToRu(property.Name)+ ": " + obj.Properties[property.Name].Value.ToString());
}
}
catch
{
//Add codes to manage more informations
}
}
StringBuilder1.AppendLine();
}
}
catch
{
//Win 32 Classes Which are not defined on client system
}
return StringBuilder1.ToString();
}
Как можно экспортировать эти же данные в табличном виде в excel ?