Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

jwradhe

@jwradhe
About
Posts
7
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Problems when reading a Excel file with numbers.
    J jwradhe

    Thanks alot, worked perfect, and i learned one new thing! :) Have a good day!

    C# help

  • Problems when reading a Excel file with numbers.
    J jwradhe

    Hi! When i run my code with a excel document with words in, it works, but at fast as i read a document with numbers only i get error on marked line in code.

    if (c.DataType.Value == CellValues.SharedString)

    and the error is:

    An error occurred!!!: The object reference has not been specified to an instance of an object.

    I have a little hard to see why this happends, hope on you experts!

    using (SpreadsheetDocument myDoc = SpreadsheetDocument.Open(input, true))
    {

                    WorkbookPart workbookPart = myDoc.WorkbookPart;
                    WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();
                    SheetData sheetData = worksheetPart.Worksheet.Elements().First();
    
                    foreach (Row r in sheetData.Elements())
                    {
    
                        foreach (Cell c in r.Elements())
                        {
    
    
                            string value = c.InnerText;
    
    
                            **if (c.DataType.Value == CellValues.SharedString)**
                            {
    
                                var stringTable = workbookPart.GetPartsOfType()
                                        .FirstOrDefault();
                                if (stringTable != null)
                                {
                                    value = stringTable.SharedStringTable.ElementAt(int.Parse(value)).InnerText;
                                    GenerateBarcodeFromExcel(value, output);
                                }
    
                            }
                            else
                            {
                                GenerateBarcodeFromExcel(c.CellValue.Text, output);
                            }
                               
                        }
                    }
    
                    myDoc.Close();
    
    C# help

  • c# Search in root/subtree active directory users
    J jwradhe

    Hi!
    Im having some problem in my function to search on all users in my active directory, root and subtree.

    my ad is like this:

    ad.company
    -> se.ad.company
    -> fin.ad.company
    -> no.ad.company

    I can search , but only get some results from ad.company, not the other subtree directorys.
    What have i done wrong?

    And this is my code:

    private void AutoCompleteTextBox_ReferenceUser()
    {

            try
            {
                var attributeName = "sn";
                string OU = "DC=ad,DC=company";
                var searchString = textBox\_manager.Text;
                var ent = new DirectoryEntry("GC://" + OU);
                var mySearcher = new DirectorySearcher(ent);
                mySearcher.Filter = string.Format("(&(anr={0})(objectCategory=user)(objectClass=user))", attributeName, searchString);
    
                SearchResultCollection result = mySearcher.FindAll();
    
                List names = new List();
    
                foreach(SearchResult sr in result)
                    {
                        var n = sr.Properties\["cn"\]\[0\].ToString();
                        if (!names.Contains(n))
                        {
                            stringCollection.Add(n);
                        }
                    }
    
                textBox\_referenceuser.AutoCompleteMode = AutoCompleteMode.Suggest;
                textBox\_referenceuser.AutoCompleteSource = AutoCompleteSource.CustomSource;
                textBox\_referenceuser.AutoCompleteCustomSource = stringCollection;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    
    C# csharp windows-admin help question

  • Run powershell in C#
    J jwradhe

    2021-09-20 is the result from PS command

    C / C++ / MFC question csharp com windows-admin help

  • Run powershell in C#
    J jwradhe

    Hi! Yeah if possible i want it in C# only. I trid the code but i gives this: 0001-01-01 00:00:00 +00:00

    C / C++ / MFC question csharp com windows-admin help

  • Run powershell in C#
    J jwradhe

    Hi! I am pretty new to this, but im trying to present when the latest winupdate was done on computer, and only found in powershell to present that, and i tried to run it in C#, but no error and no result. I understand that im doing wrong, but what is the best way to do this?

    // Get Latest Windows Update
    private void LastWinUpd()
    {

            Runspace runspace = RunspaceFactory.CreateRunspace();
            runspace.Open();
    
            PowerShell ps = PowerShell.Create();
            ps.Runspace = runspace;
    
            //ps.Commands.AddScript("gwmi win32\_quickfixengineering | Select-Object -expandProperty 'installedon' | sort installedon -desc | Select-Object -First 1 | Get-Date -Format 'yyyy - MM - dd K'");
    
            ps.AddCommand("$a = (New - Object - com 'Microsoft.Update.AutoUpdate').Results");
            ps.AddCommand("$a.LastInstallationSuccessDate | Get - Date - Format 'yyyy-MM-dd K'");
    
            Collection results = ps.Invoke();
    
            runspace.Close();
    
            StringBuilder stringBuilder = new StringBuilder();
            foreach (PSObject obj in results)
            {
                text\_LastWinUpd.Text = obj.ToString();
            }
           
        }
        // END
    
    C / C++ / MFC question csharp com windows-admin help

  • Run powershell in C#
    J jwradhe

    Hi! I am pretty new to this, but im trying to present when the latest winupdate was done on computer, and only found in powershell to present that, and i tried to run it in C#, but no error and no result. I understand that im doing wrong, but what is the best way to do this?

    // Get Latest Windows Update
    private void LastWinUpd()
    {

            Runspace runspace = RunspaceFactory.CreateRunspace();
            runspace.Open();
    
            PowerShell ps = PowerShell.Create();
            ps.Runspace = runspace;
    
            //ps.Commands.AddScript("gwmi win32\_quickfixengineering | Select-Object -expandProperty 'installedon' | sort installedon -desc | Select-Object -First 1 | Get-Date -Format 'yyyy - MM - dd K'");
    
            ps.AddCommand("$a = (New - Object - com 'Microsoft.Update.AutoUpdate').Results");
            ps.AddCommand("$a.LastInstallationSuccessDate | Get - Date - Format 'yyyy-MM-dd K'");
    
            Collection results = ps.Invoke();
    
            runspace.Close();
    
            StringBuilder stringBuilder = new StringBuilder();
            foreach (PSObject obj in results)
            {
                text\_LastWinUpd.Text = obj.ToString();
            }
           
        }
        // END
    
    C / C++ / MFC question csharp com windows-admin help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups