- Drop that goto (and please don't use it ever again, for anything). Instead: Toggling a boolean variable is as easy as this:
tif = !tif;
- Doesn't help a lot here though because the change will not reflect in buffer. After you create buffer it keeps its value forever.
- You're using the third parameter of the Stream.Write-method wrongly - at least judging from your described intent. It's supposed to be the amount of bytes from buffer, starting at position 0, that should be written into the file stream. But buffer is only 1 byte long and bits says there should be 32 bytes. That's where you are "outside of the array bounds".
- Your while-loop will run forever because bits will be > 0 forever.
You should start using the debugger. Place a breakpoint at the start of your method (first line or opening brace) by placing the cursor there and pressing F9. Then start your program in debug mode by pressing F5. Then step over the execution line-by-line by pressing F10* while you inspect the values of your variables by hovering with the mouse cursor over it. Compare the values you expect with their actual values and when there's a difference try to find out, why.
*: Take a look at further ways of stepping through your code while debugging: In the Debug-Menu and/or the Debugging-Toolbar (and the Debugger-documentation).
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
This is my first ever attempt at coding against AD, so bear with me...
Here's what I have:
PrincipalContext AD = new PrincipalContext(ContextType.Domain, serverName);
UserPrincipal u = new UserPrincipal(AD);
PrincipalSearcher search = new PrincipalSearcher(u);
foreach (UserPrincipal result in search.FindAll().OrderBy(x => x.DisplayName))
When I run this I get back a list of objects. But what I get back is only a partial list. Some users are there, some are not.
Anyone see what I'm doing wrong?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
I'm trying to use only Alphanumeric characters an must use 4. No more or less.
The Code I'm using is below. If I remove the For Loop and can type Alphanumeric values in the textbox but I can seem to type only 4 characters. maxLenght says: cannot convert type in to bool. (Must be 4 characters). I appreciate your help.
//string value;string s = BacBox.Text;
int maxLenght = 4;
Regex r = new Regex("^[a-zA-Z0-9]*$");
for (int i = 0; i = maxLenght; i++)
BacBox.Text = s;
MessageBox.Show("Enter 4 alphanumeric characters only");
cmd.Connection = con;
cmd.CommandText = "Insert into Table1 (FileName) Values (@FileName)";
SqlParameter param = new SqlParameter("@FileName", SqlDbType.NVarChar);
foreach (FileInfo fi in fileNames)
param.Value = fi.Name;
if (cmd.ExecuteNonQuery() <1)
// report the error
Console.WriteLine(fi.Name); // Verify via Console window that the "fi" variable really is changing
Thank you for your reply Eddy.
Actually I had already tried this approach but I cannot get the "System.Windows.Forms" using directive not grayed. The event on clicked item method is likned to SelectedItemChanged PropertyThis might be for you a basic issue to deal with?
Consequently I get an error message about a missing definition for "SelectedNode" property.