Skip to content

Commit

Permalink
Add OS version
Browse files Browse the repository at this point in the history
  • Loading branch information
fredatgithub committed Mar 15, 2019
1 parent 93fd88a commit 355b9a8
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions SaveWin10Pictures/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ private static void Main()
List<string> files = new List<string>();
int counter = 0;
//string OSVersion = Environment.OSVersion.ToString(); // 6.2 ON Win 10
string OSVersion = GetOSInfo();
//string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string userName = Environment.UserName;
// remove domain if any
Expand Down Expand Up @@ -184,5 +185,89 @@ public static List<string> GetFilesFileteredBySize(DirectoryInfo directoryInfo,

return result;
}

public static string GetOSInfo()
{
//Get Operating system information.
OperatingSystem os = Environment.OSVersion;
//Get version information about the os.
Version vs = os.Version;

//Variable to hold our return value
string operatingSystem = "";

if (os.Platform == PlatformID.Win32Windows)
{
//This is a pre-NT version of Windows
switch (vs.Minor)
{
case 0:
operatingSystem = "95";
break;
case 10:
if (vs.Revision.ToString() == "2222A")
operatingSystem = "98SE";
else
operatingSystem = "98";
break;
case 90:
operatingSystem = "Me";
break;
default:
break;
}
}
else if (os.Platform == PlatformID.Win32NT)
{
switch (vs.Major)
{
case 3:
operatingSystem = "NT 3.51";
break;
case 4:
operatingSystem = "NT 4.0";
break;
case 5:
if (vs.Minor == 0)
operatingSystem = "2000";
else
operatingSystem = "XP";
break;
case 6:
if (vs.Minor == 0)
operatingSystem = "Vista";
else if (vs.Minor == 1)
operatingSystem = "7";
else if (vs.Minor == 2)
operatingSystem = "8";
else
operatingSystem = "8.1";
break;
case 10:
operatingSystem = "10";
break;
default:
break;
}
}
//Make sure we actually got something in our OS check
//We don't want to just return " Service Pack 2" or " 32-bit"
//That information is useless without the OS version.
if (operatingSystem != "")
{
//Got something. Let's prepend "Windows" and get more info.
operatingSystem = "Windows " + operatingSystem;
//See if there's a service pack installed.
if (os.ServicePack != "")
{
//Append it to the OS name. i.e. "Windows XP Service Pack 3"
operatingSystem += " " + os.ServicePack;
}
//Append the OS architecture. i.e. "Windows XP Service Pack 3 32-bit"
//operatingSystem += " " + getOSArchitecture().ToString() + "-bit";
}
//Return the information we've gathered.
return operatingSystem;
}
}
}

0 comments on commit 355b9a8

Please sign in to comment.