Note that there are some explanatory texts on larger screens.

plurals
  1. POExecution stops without any exception
    text
    copied!<p>I have some code to delete user profiles over the network using a service that runs on the client computers that looks like this:</p> <pre><code>public static void DeleteProfiles() { ConsoleWrapper.WriteLine("We're in DeleteProfiles()"); try { string[] users = GetUsers(); ConsoleWrapper.WriteLine("Users gotten"); if (users == null || users.Length == 0) { DeletingProfiles = false; ConsoleWrapper.WriteLine("Null or no user loaded"); return; } DirectoryInfo oInfo = new DirectoryInfo("C:/Users"); if (!oInfo.Exists) oInfo = new DirectoryInfo("C:/Documents and Settings"); ConsoleWrapper.WriteLine("Profile folder gotten."); ConsoleWrapper.WriteLine("User Directory: " + oInfo.FullName); ConsoleWrapper.WriteLine("\nDirectories to be deleted:"); DirectoryInfo[] SubDirectories = oInfo.GetDirectories(); foreach (DirectoryInfo oSubDir in SubDirectories) { bool match = false; foreach (string user in users) { if (user == null) continue; if (oSubDir.Name.ToLower() == user.ToLower()) { ConsoleWrapper.WriteLine("Matched: " + oSubDir.FullName); match = true; break; } } if (match) continue; try { ConsoleWrapper.WriteLine(oSubDir.FullName); DeletePath(oSubDir.FullName); } catch (Exception ex) { ConsoleWrapper.WriteLine(ex.StackTrace); } } } catch (Exception dirEx) { ConsoleWrapper.WriteLine(dirEx.Message); } } </code></pre> <p>The WriteLine method from the ConsoleWrapper actually appends data to a txt file, because that's the easiest way I can think of to debug on a different machine. </p> <p>This exact code works when I use it in a command-line application, but when I try to use it in the Windows service, it simply writes "We're in DeleteProfiles()." As you'll notice, I've caught every "catchable" exception, but I still don't understand what's going on.</p> <p>All the client computers are exhibiting this problem, but it works well on both my desktop and laptop. What am I doing wrong?</p> <p>For the DeletePath code, see <a href="http://www.vbdotnetforums.com/windows-services/16909-deletedirectory-throws-exception.html#post51470" rel="nofollow noreferrer">http://www.vbdotnetforums.com/windows-services/16909-deletedirectory-throws-exception.html#post51470</a>. I practically lifted it and converted it to C# code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload