|
Okay, now this is making no sense.
If I put a break point on the if statement, and then on the internal return statement, and I run my tests, it seems to hit the right sequence of breakpoints.
HOWEVER, if I do the same thing, and this time, on the locals pane, hit the + button to see the values of the "this," it starts hitting the wrong sequence of breakpoints and flipping the value of the boolean.
I'm so confused.
~Andy
|
|
|
|
|
the threadID and the stacktrace come in handy when more than one thread is involved, so you can see how and why some code gets executed when you don't expect it to be.
if you think you are through observing things, and couldn't pinpoint the problem, it becomes time to suspect Visual Studio and/or .NET; yours wouldn't be the first problem today that disappears after a reinstall. See here[^]
|
|
|
|
|
aespielberg wrote: public double PolygonArea2
{
get{...
currAreaValid = true;
}
}
There's the line that sets the boolean to true. Remember looking at objects inside the debugger will evaluate the object's properties. So looking at this inside the debugger can indeed set currAreaValid to true.
Breakpoints aren't active during the debugger's property evaluation, so even if you have a breakpoint placed on that line, the value will change to true without triggering the breakpoint.
|
|
|
|
|
Right-click on a an arbitrary folder, choose Properties -> choose Security-tab -> Advanced -> choose Permissions-tab -> Edit... On the upper part of the window there is now a combobox saying "Apply onto" and the possible options are "This folder only", "This folder, subfolders and files", "This folder and subfolders", "This folder and files", "Subfolders and files only","Subfolders only" and "Files only". How do I modify this programmatically using C#?
|
|
|
|
|
I figured it out:
public struct PermissionInfo
{
public FileSystemRights fileSystemRight;
public AccessControlType allowOrDeny;
public PermissionInfo(FileSystemRights fileSystemRight_, AccessControlType allowOrDeny_)
{
fileSystemRight = fileSystemRight_;
allowOrDeny = allowOrDeny_;
}
}
public enum ApplyOnto
{
THIS_FOLDER_ONLY = 0,
THIS_FOLDER_AND_SUBFOLDERS_AND_FILES = 1,
THIS_FOLDER_AND_SUBFOLDERS = 2,
THIS_FOLDER_AND_FILES = 3,
FILES_AND_SUBFOLDERS_ONLY = 4,
SUBFOLDERS_ONLY = 5,
FILES_ONLY = 6
}
private static InheritanceFlags[] inheritanceFlags = new InheritanceFlags[]
{
InheritanceFlags.None,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
InheritanceFlags.ContainerInherit,
InheritanceFlags.ObjectInherit,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
InheritanceFlags.ContainerInherit,
InheritanceFlags.ObjectInherit
};
private static PropagationFlags[] propagationFlags = new PropagationFlags[]
{
PropagationFlags.None,
PropagationFlags.None,
PropagationFlags.None,
PropagationFlags.None,
PropagationFlags.InheritOnly,
PropagationFlags.InheritOnly,
PropagationFlags.InheritOnly
};
public static void setDirectoryPermission(string directory, string user, PermissionInfo[] permissionInfo, ApplyOnto applyOnto)
{
DirectoryInfo myDirectoryInfo = new DirectoryInfo(directory);
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
for (int i = 0; i < permissionInfo.Length; i++)
{
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(
user,
permissionInfo[i].fileSystemRight,
inheritanceFlags[(int)applyOnto],
propagationFlags[(int)applyOnto],
permissionInfo[i].allowOrDeny
));
}
myDirectoryInfo.SetAccessControl(myDirectorySecurity);
}
modified on Wednesday, January 13, 2010 4:11 AM
|
|
|
|
|
Thanks for the wonderful post
I added another parameter to your setDirectoryPermission (..) function - ApplyTo. It is equivalent to "Apply theese permissions to objects and / or containers within this container only" checkbox in the object-tab, which is also the option ApplyOnto .. I think that the code is finished
For this purpose, I changed PropagationFlags with two-dimensional array and I added one more enum "ApplyTo"
Here's how it looks:
public struct PermissionInfo
{
public FileSystemRights fileSystemRight;
public AccessControlType allowOrDeny;
public PermissionInfo(FileSystemRights fileSystemRight_, AccessControlType allowOrDeny_)
{
fileSystemRight = fileSystemRight_;
allowOrDeny = allowOrDeny_;
}
}
public enum ApplyOnto
{
THIS_FOLDER_ONLY = 0,
THIS_FOLDER_AND_SUBFOLDERS_AND_FILES = 1,
THIS_FOLDER_AND_SUBFOLDERS = 2,
THIS_FOLDER_AND_FILES = 3,
FILES_AND_SUBFOLDERS_ONLY = 4,
SUBFOLDERS_ONLY = 5,
FILES_ONLY = 6
}
public enum ApplyTo
{
ObjectAndChilds = 0,
ThisObjectOnly = 1
}
private static InheritanceFlags[] inheritanceFlags = new InheritanceFlags[]
{
InheritanceFlags.None,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
InheritanceFlags.ContainerInherit,
InheritanceFlags.ObjectInherit,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
InheritanceFlags.ContainerInherit,
InheritanceFlags.ObjectInherit
};
private static PropagationFlags[,] propagationFlags = new PropagationFlags[,]
{ {PropagationFlags.None,
PropagationFlags.NoPropagateInherit},
{PropagationFlags.None,
PropagationFlags.NoPropagateInherit},
{PropagationFlags.None,
PropagationFlags.NoPropagateInherit},
{PropagationFlags.None,
PropagationFlags.NoPropagateInherit},
{PropagationFlags.InheritOnly,
PropagationFlags.InheritOnly| PropagationFlags.NoPropagateInherit},
{PropagationFlags.InheritOnly,
PropagationFlags.InheritOnly| PropagationFlags.NoPropagateInherit},
{PropagationFlags.InheritOnly,
PropagationFlags.InheritOnly| PropagationFlags.NoPropagateInherit}
};
public static void setDirectoryPermission(string directory, string user, PermissionInfo[] permissionInfo, ApplyOnto applyOnto, ApplyTo applyTo)
{
DirectoryInfo myDirectoryInfo = new DirectoryInfo(directory);
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
for (int i = 0; i < permissionInfo.Length; i++)
{
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(
user,
permissionInfo[i].fileSystemRight,
inheritanceFlags[(int)applyOnto],
propagationFlags[(int)applyOnto, (int)applyTo],
permissionInfo[i].allowOrDeny
));
}
myDirectoryInfo.SetAccessControl(myDirectorySecurity);
}
|
|
|
|
|
Hi I really need a pointer in the right direction im a noob to C# and coding in general but im learning. Ive googled around and cant find anything that can really help me.
I want to capture an image from a camera attached to my PCI Capture card via composite. I can get the image in a win form Picture box by using DirectX.Capture so thats fine but.. I need to know how I send this "Capture" over the network and see this in another form on another computer on the same network.
Just a nod in the right direction please.
Thanks
|
|
|
|
|
Hi,
You have 2 objectives:
1. You need a solution to save the images from PictureBox control.
2. You need a solution to send the saved images over the network.
A solution:
1. You can save the image from PictureBox control once per second (or less time.. as you wish) with the help of Timer control;
2. You can serialize the saved image and send it over the network.
This is in big steps what you need to do, but It's a first look solution!
Cheer's,
Alex Manolescu
|
|
|
|
|
Hi.
i want to find all * characters in a string and showing them red color in a richtextbox. How can i do that?
string str = "asd***asd***dfg***wer**";
in a richtextbox;
asd***asd***dfg***wer** --->(bold characters should be red)
|
|
|
|
|
A solution:
1. Convert the string to char array
2. Iterate through the char array
3. Compare each char from the array with the char *
3.1. if TRUE: write with red color into the richTextBox control
3.2. if FALSE: write current char to richTextBox control
This is it!
Cheer's,
Alex Manolescu
|
|
|
|
|
You can skip 1 and just enumerate the string as it is.
|
|
|
|
|
Hi,
there are two ways to get there:
1. using the RTB Control:
locate the substring of interest (maybe with Find), select it (SelectionStart, SelectionLength), set its color (SelectionColor)
2. using the RTF text string:
get the RTF property
assuming there is an appropriate color table present already with "red" at position 1, replace * by \cf1 *\cf0
set the RTF property again
BTW: inserting a colortable is doable too; create a real RTF file with WordPad, make sure it contains red text, save the file, then use Notepad to see how RTF encodes its commands.
|
|
|
|
|
Isnt there any sample code?
|
|
|
|
|
|
Hi All
I am creating an application in order to get the DOM info of a Web Page.
I cannot extract a TBODY tag using my application.
I am using
*the control WebBrowser shipped by Visual Studio
*a reference to the Com Microsoft.mshtml 7.0.3300.0
If I use the "Internet Explorer Developer Toolbar" I can see all information I need.
The <TBODY> tag has id "tbody_rank_by_level" and carries a list of <TR> tags full of data
that are showed in attributes innertHTML and innertText.
Using the code below innertHtml and innertText are both null.
What I am doing wrong?
mshtml.IHTMLDocument3 domDoc = this.webBrowser.Document.DomDocument as mshtml.IHTMLDocument3;
mshtml.IHTMLElement element = domDoc.getElementById("tbody_rank_by_level");
String innerHtml = element.innerHTML;
String innerText = element.innerText;
modified on Monday, January 11, 2010 3:07 PM
|
|
|
|
|
|
Hello,
I'm wondering if there is any built in function in c# .net that can write/insert a string over/into another string and based on a "transparent" character parts of the first string is preserved?
You have two strings, strA and strB.
strA is the "base" string and strB is the "outside" string we want to merge into strA. strB overwrites strA unless the character is a blank space character.
I could/will create my own function that accomplish this but I'm curios if there's any build in c# .net function that does this. Is there any name for such operation?
Here are some examples of how I want to merge the strings:
Example 1:
string strA = "This is string A";
string strB = " This is string B";
Example 2: "Transparent blank space character"
string strA = "This is string A";
string strB = " This is string B";
Example 3:
string strA = "This is string A and it is longer then string B";
string strB = " This is string B";
|
|
|
|
|
There's no built in method to do this. You'd at least, have to try a Regular Expression to do something like this. I have no idea how since I'm no RegEx expert.
But, it wouldn't be hard to implement something like this yourself. I'll give you a hint: StringBuilder is perfect for this.
|
|
|
|
|
for example 1:
String str = strA.Trim() + " " + strB.Trim();
for other examples, you need to implement on your own.
|
|
|
|
|
how can i create an xml file by filling a datagrid .. to note here that we have to create an unexisting xml file... and i want to know how to name the datagrid tables and add rows knowing how much rows does the user want to add
|
|
|
|
|
Hey,
I'm trying to make a program to automaticly check my downloads (because the internal Grabit-check annoise me and I wan't some practice).
I create a new thread for par2cmdline and can get information from the commandline except for this block:
There are 1 recoverable files and 0 other files.
The block size used was 384000 bytes.
There are a total of 282 data blocks.
The total size of the data files is 108185219 bytes
I only recieve the last line [The total size of the data files is 108185219 bytes] but i need the first one.
Here's a piece of my code:
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "par2";
info.Arguments = "r \"existing par2 file\"";
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
info.CreateNoWindow = true;
Process proc = new Process();
proc.StartInfo = info;
proc.Start();
Char[] buffer;
while (!proc.HasExited)
{
string tekst = proc.StandardOutput.ReadLine();
result = tekst;
}
proc.WaitForExit();
Result is a public var witch I read by a timer, fetch some information and make a progressbar change.
|
|
|
|
|
Hi,
Is the result being overwritten with the next string from standard output before the timer driven routine has read it? Why not remove the timer and process the strings as they arrive, e.g.
while (!proc.HasExited)
{
string tekst = proc.StandardOutput.ReadLine();
ProgressUpdate(tekst);
}
Alan.
|
|
|
|
|
You're trying to get the console output generated by an app. There typically can be two output streams, one is the (regular) output stream (stdout in C environment), the other the error stream (stderr in C environment). The former typically is used for regular output, the latter for error reporting (but you can't really tell just by looking at it).
You can easily get both of them asynchronously (i.e. after the process has finished) by using Process.StandardOutput.ReadToEnd() and Process.StandardError.ReadToEnd() .
If you want to get them both while the process is still running, you need more than one thread, as the read calls (like the ReadLine you're using now) are blocking. There are two ways to get there:
1. use 2 threads, each having a loop such as yours;
2. use 2 events: Process.OutputDataReceived and Process.ErrorDataReceived which probably run on ThreadPool threads automatically (cfr this article[^])
wathever choice you make, be careful about thread safety (in a WinForms app your threads or event handlers would not be allowed to touch GUI Controls directly (for more, see rhis article[^])
|
|
|
|
|
Hi All,
I want to merge 2 tables.
These 2 tables have different columns but the no.of records same.
DataTable dt1, DataTable dt2;
dt1: contains records like below
===============================
colA colB colC
----------------
a1 b1 c1
a2 b2 c2
a3 b3 c3
dt2: contains records like below
===============================
colD colE colF
----------------
d1 e1 f1
d2 e2 f2
d3 e3 f3
I have to make these two table into one single table like below
Required DataTable
colA colB colC colD colE colF
--------------------------------
a1 b1 c1 d1 e1 f1
a2 b2 c2 d2 e2 f2
a3 b3 c3 d3 e3 f3
How can we do that?
I approached like, taken a DataTable and added columns of dt1 and dt2 the this table. then added the records to main DataTable through looping each record of dt1 and dt2.
Is there any other way do this with out using loop statements.
Both the tables are different, they don't have any relation between them, only the no.of records were same.
Please suggest me how to this.
Thanks in advance.
|
|
|
|
|
There's two way to do this without using a loop. The best way is to have your database server get you the data in the fashion you want using a SELECT query. An alternative is to use LIST to do it. In either case, hopefully, you have key relationships between these two tables, right?
|
|
|
|
|