public ComputerInformationView()
        {
            InitializeComponent();

            var computerinfo = new ComputerInformation();
            DataContext = computerinfo;

            OsTextblock.DataContext = this;
        }
Exemplo n.º 2
0
        private void SaveScan(object sender, RoutedEventArgs e)
        {
            var fileName = Environment.MachineName + "_" + Environment.UserName;
            if (!Directory.Exists(Environment.CurrentDirectory + @"\Scans\"))Directory.CreateDirectory(Environment.CurrentDirectory + @"\Scans\");

            if (File.Exists(Environment.CurrentDirectory + @"\Scans\" + fileName + ".txt")) File.Delete(Environment.CurrentDirectory + @"\Scans\" + fileName + ".txt");
            var compInfo = new ComputerInformation();
            using (var SW = new StreamWriter(Environment.CurrentDirectory + @"\Scans\" + fileName + ".txt", false))
            {
                SW.WriteLine("Computer Name : {0}{4}Current User : {1}{4}Operating System : {2}{4}{3}{4}", compInfo.ComputerName, compInfo.CurrentUser, compInfo.OperatingSystem, MappedDrives(), Environment.NewLine);
                foreach (var item in compInfo.PrinterInfo())
                {
                    SW.Write("Printer Name : {0} Network Name : {1}{2}", item.DisplayName, item.NetworkName, Environment.NewLine);
                }
                foreach (var content in from object item in UserScanTreeView.Items select item as TreeViewItem)
                {
                    SW.WriteLine("{0}[{1}]{0}", Environment.NewLine, content.Header);
                    foreach (var data in content.Items)
                    {
                        SW.WriteLine(data.ToString());
                    }
                }
            }
        }
Exemplo n.º 3
0
 private string MappedPrinters()
 {
     var compInfo = new ComputerInformation();
     var stringbuilt = new StringBuilder();
     foreach (var printer in compInfo.MappedPrintersList)
     {
         stringbuilt.AppendFormat("Printer : {0}{1}", printer, Environment.NewLine);
     }
     return stringbuilt.ToString();
 }
Exemplo n.º 4
0
 private string MappedDrives()
 {
     var compInfo = new ComputerInformation();
     var stringbuilt = new StringBuilder();
     foreach (var drives in compInfo.MappedDrivesList)
     {
         stringbuilt.AppendFormat("Drive : {0}{1}", drives, Environment.NewLine);
     }
     return stringbuilt.ToString();
 }