Click here to Skip to main content
15,880,608 members
Home / Discussions / C#
   

C#

 
AnswerRe: Converting from C to C# Pin
Bernhard Hiller15-Oct-12 22:35
Bernhard Hiller15-Oct-12 22:35 
GeneralRe: Converting from C to C# Pin
AseelHadlaq16-Oct-12 5:49
AseelHadlaq16-Oct-12 5:49 
GeneralRe: Converting from C to C# Pin
Pete O'Hanlon16-Oct-12 6:21
mvePete O'Hanlon16-Oct-12 6:21 
QuestionDirectoryEntry Questions Pin
Erick Kinnee15-Oct-12 4:37
Erick Kinnee15-Oct-12 4:37 
QuestionRe: DirectoryEntry Questions Pin
Richard MacCutchan15-Oct-12 4:45
mveRichard MacCutchan15-Oct-12 4:45 
AnswerRe: DirectoryEntry Questions Pin
Erick Kinnee15-Oct-12 4:49
Erick Kinnee15-Oct-12 4:49 
GeneralRe: DirectoryEntry Questions Pin
Richard MacCutchan15-Oct-12 5:04
mveRichard MacCutchan15-Oct-12 5:04 
AnswerRe: DirectoryEntry Questions Pin
Eddy Vluggen15-Oct-12 5:04
professionalEddy Vluggen15-Oct-12 5:04 
What is "over usage"? My apps are using a lot of ints, do you think it could leak memory due to that? It won't, and speed is not an indication for a memory-leak. The amount of used memory is an indication.

A few remarks on the code;
if (member.SchemaClassName == "Group")
{
    object admMembers = member.Invoke("members", null);
    foreach (object admMember in (IEnumerable)admMembers)
    {
        DirectoryEntry membername = new DirectoryEntry(admMember);
        DataRow dr = table.NewRow();
        dr["Machine"] = remMachine.Name.ToString();
        dr["Group"] = member.Name.ToString();
        dr["User"] = membername.Name.ToString();
        table.Rows.Add(dr);
        membername.Dispose();
    }
}
//Just a user, write it down
else if (member.SchemaClassName == "User")
{
    DataRow dr = table.NewRow();
    dr["Machine"] = remMachine.Name.ToString();
    dr["Group"] = "Administrators";
    dr["User"] = member.Name.ToString();
    table.Rows.Add(dr);
    member.Dispose();
}

Reads to me as;
if (something)
  membername.Dispose(); // are you sure? :)
else
  member.Dispose();

I'd expect something along these lines;
foreach (object groupMember in (IEnumerable)members)
{
  using (var member = new DirectoryEntry(groupMember))
  {
    //If it's a group, get the members.
    if (member.SchemaClassName == "Group")
..

You could gain some speed perhaps, if you had a thread for each result in there. Depends on how many results and how many cores your CPU got. A progressbar is often appreciated for longer-running tasks.
Bastard Programmer from Hell Suspicious | :suss:
if you can't read my code, try converting it here[^]

QuestionMessageBox error Pin
Saridakis Manolis14-Oct-12 23:36
Saridakis Manolis14-Oct-12 23:36 
AnswerRe: MessageBox error Pin
Sivaraman Dhamodharan14-Oct-12 23:39
Sivaraman Dhamodharan14-Oct-12 23:39 
AnswerRe: MessageBox error Pin
Pete O'Hanlon15-Oct-12 0:21
mvePete O'Hanlon15-Oct-12 0:21 
AnswerRe: MessageBox error Pin
Eddy Vluggen15-Oct-12 0:43
professionalEddy Vluggen15-Oct-12 0:43 
QuestionUnhandledException Pin
Hamid_RT14-Oct-12 3:38
Hamid_RT14-Oct-12 3:38 
AnswerRe: UnhandledException Pin
OriginalGriff14-Oct-12 3:49
mveOriginalGriff14-Oct-12 3:49 
GeneralRe: UnhandledException Pin
Hamid_RT14-Oct-12 4:14
Hamid_RT14-Oct-12 4:14 
GeneralRe: UnhandledException Pin
OriginalGriff14-Oct-12 4:25
mveOriginalGriff14-Oct-12 4:25 
GeneralRe: UnhandledException Pin
Hamid_RT14-Oct-12 5:03
Hamid_RT14-Oct-12 5:03 
GeneralRe: UnhandledException Pin
OriginalGriff14-Oct-12 5:12
mveOriginalGriff14-Oct-12 5:12 
GeneralRe: UnhandledException Pin
Hamid_RT14-Oct-12 5:25
Hamid_RT14-Oct-12 5:25 
GeneralRe: UnhandledException Pin
jschell14-Oct-12 6:59
jschell14-Oct-12 6:59 
AnswerRe: UnhandledException Pin
Eddy Vluggen14-Oct-12 3:50
professionalEddy Vluggen14-Oct-12 3:50 
GeneralRe: UnhandledException Pin
Hamid_RT14-Oct-12 4:17
Hamid_RT14-Oct-12 4:17 
GeneralRe: UnhandledException Pin
Eddy Vluggen14-Oct-12 4:22
professionalEddy Vluggen14-Oct-12 4:22 
GeneralRe: UnhandledException Pin
Hamid_RT14-Oct-12 5:08
Hamid_RT14-Oct-12 5:08 
GeneralRe: UnhandledException Pin
Eddy Vluggen14-Oct-12 8:27
professionalEddy Vluggen14-Oct-12 8:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.