using System;
using System.Management;
namespace zedilabs.com
{
class PrinterOffline
{
[STAThread]
static void Main(string[] args)
{
// Set management scope
ManagementScope scope = new ManagementScope(@"\root\cimv2");
scope.Connect();
// Select Printers from WMI Object Collections
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("SELECT * FROM Win32_Printer");
string printerName = "";
foreach (ManagementObject printer in searcher.Get())
{
printerName = printer["Name"].ToString().ToLower();
if (printerName.Equals(@"hp deskjet 930c"))
{
Console.WriteLine("Printer = " + printer["Name"]);
if (printer["WorkOffline"].ToString().ToLower().Equals("true"))
{
// printer is offline by user
Console.WriteLine("Your Plug-N-Play printer is not connected.");
}
else
{
// printer is not offline
Console.WriteLine("Your Plug-N-Play printer is connected.");
}
}
}
}
}
}
-===============
using System;
public class Program
{
public static void Main()
{
string st = "https://track.test.com/order/09a41f0b-f28d-4628-b99a-7c8cf642d0d7";
string st1 = "https://track.test.com/order/b08fdc6b-9c2d-4c52-a916-7a03cdd927c8/track?intl=en-US";
string[] ord = st1.Split(new string[]{"/"}, StringSplitOptions.None);
int i=0;
foreach(var item in ord){
Console.WriteLine(i+" "+item);
i++;
}
}
}