|
Had to look that up!
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Oops! Sorry about that - corrected.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
OriginalGriff wrote: I am an idiot!
IMO you're quite OK, well, most of the time.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
DateTime.Now has properties that give you the current month and year. You'll have to figure out the quarter yourself but it's a simple
DateTime now = DateTime.Now;
if (now.Month < 4)
{
}
else if (now.Month < 7)
{
}
else . . .
EDIT: I need to refresh my browser more often
|
|
|
|
|
I have created two form,When I Open form1 and then close it then open Form2 and close it.After that reopen form1 then Label field text is getting removed in form1.
Thanx in Adv.
|
|
|
|
|
Check the Form1_load event code also unload event if the label text is clearing?
|
|
|
|
|
Hi all
I want to parse a sentence like:father(X,Y):-parant(X,Y),male(X).and some other sentences that the structure of these sentences are the same but they have variable length.
I want to save each segment of these sentences in a Datatable.
What is your idea about segmentation of these sentences?(I'm using text.Split, Do you have better suggestion?)
If i use split methode i must use it in several times.
Maybe you have better suggestion that i can use it easier?!
modified on Friday, January 22, 2010 3:14 AM
|
|
|
|
|
Why have you got to use it several times?
I assume it's because you need to break it differently depending on the delimiters - so you know it is X because it is preseeded by "(", followed by "," and the name is in front?
If so, then why not use a Regex? Shouldn't be too complex if your sentances are all of the form A(B,C) (E,F),G(H)
A Regex could split that into named groups pretty easily.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Thx for your reply;
I want parse this sentence and some other sentence like this to these segment:
sentence : grandparant(X,Z):-parant(X,Y),parant(Y,Z).
segment : father X Y parant X Y parant Y Z
(variable X,Y,Z,.. must be upercase)
what is the best way?
Note:I think that if i want to use Regex , i must searh some particular expression but i want to parse any expression like above.
modified on Friday, January 22, 2010 4:59 AM
|
|
|
|
|
A regex is probably the easy way:
(?<Parent>(?<PName>\w+)\((?<PX>.+),(?<PZ>.+)\)):-(?<Children>.*)
This does not do the complete job: It breaks it into "Parent" which consists of "PName" and "PX" and "PZ", and "Children" which is everything else. It is pretty simple to expand to break the children down as well, but I don't have the time to do everything for you! Get a copy of Expresso[^]which will help you understand what is going on - it's free and really works well.
Then all you have to do is slide that into your C# and it should do the parse for you!
After that, a bit of validation, and you are away.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
i am having mesh of a man ...
i want to make that mesh to walk based on mouse click of the mouse..
thank's
|
|
|
|
|
You are welcome!
|
|
|
|
|
The table (Password) has only 1 column (Password1) and only 1 row. It is also the PrimaryKey.
I can retrieve the password:
thePassword =
from tt in MainMenu.db.Password
select tt;
try
{
password = thePassword.ElementAt(0).Password1;
...
I am trying to change the value.
if ((from tt in MainMenu.db.Password
select tt).Count() > 0)
{
Password zz = MainMenu.db.Password.Single();
zz.Password1 = newPassword;
try
{
MainMenu.db.SubmitChanges();
}
...
I get the runtime error "A member defining the identity of the object cannot be changed ..."
|
|
|
|
|
as a practice, password column shouldn't be the primary key because you may want to change it later. Also, more than one users can have the same password.
Usually username could be used as a key or simply adding a new id.
Nigel Mackay wrote: I get the runtime error "A member defining the identity of the object cannot be changed ..."
Looks like that you are trying to change the password => primary key..
|
|
|
|
|
Removed the primary key assignment. Still gives same problem.
There is only one password in this app, and it is not there to discriminate between users, it is there because certain dangerous operations require a password so that only competent workers can do them!!
Just think of it as a table that stores only 1 string.
|
|
|
|
|
Found problem. Must have a Primary Key, so added another column to be the primary Key and it works.
|
|
|
|
|
Som Shekhar wrote: Usually username could be used as a key or simply adding a new id.
I suggested you that... You said you tried it?
Nigel Mackay wrote: Found problem. Must have a Primary Key, so added another column to be the primary Key and it works.
|
|
|
|
|
I actually misinterpretted your answer, seeing only the bit about not using password as the primary key, and not adding another column for userID, because I don't need it, as I ony have one password.
I later remembered that inserts, deletes and changes only work if there is a primary key.
So I have a column for primary key with only 1 row in the table. And it will always only be 1 row!!
|
|
|
|
|
You always need an ID as a primary key. Even if you don't need it, always make it a point to add a key. There has to be one column in any table with unique values. Just as a practice. its a good habit.
|
|
|
|
|
Every now and again one forgets
|
|
|
|
|
i'm trying to create a code group for CAS, i created a key file using sn.exe. and assigned that key to the assembly using
[assembly: AssemblyKeyFile(@"C:\caskey.snk")]
and built the project. but when i'm trying to create the code group using the strong name by importing the assembly file it says "The import failed. the assembly does not appear to be valid"
can any one tell me what might be wrong...
|
|
|
|
|
thanx for all who worked on solving my problem, i found the cause, it was version incompatibility.
i used the vs 2008 and framework 2.0 and the mscorcfg.msc was framework 1.1 ,that was the cause ..
|
|
|
|
|
Hi,
How to get a list of all the shared folder and get the share permission for each one?
I tried to use ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_LogicalShareSecuritySetting");
But the line of code above does not return shared folder created by code. If i manually create the folder and set it as Shared folder through windows, the shared folder can be obtain from Win32_LogicalShareSecuritySetting. Just for information, the share and security setting for both folder created through code and manually created is the same. But if the shared folder created using code, it fails to return using Win32_LogicalShareSecuritySetting.
If i use Win32_Share, i'm able to get all the share folders but the problem is i cannot use the method ("GetSecurityDescriptor") below to obtain the AccessMask or the share permission information. It will throw exception because GetSecurityDescriptor is not a method under Win32_Share:
ManagementBaseObject outParamsMthd =
m.InvokeMethod("GetSecurityDescriptor", null, options);
Below is the code snippet to obtain shared folder permission information for user name "Everyone"
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_LogicalShareSecuritySetting");
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
string shareName = m["Name"].ToString();
string shareLocalPath = ShareManager.GetShareLocalPath(shareName);
Console.WriteLine(shareLocalPath);
if (folderPath == shareLocalPath)
{
InvokeMethodOptions options = new InvokeMethodOptions();
ManagementBaseObject outParamsMthd =
m.InvokeMethod("GetSecurityDescriptor", null, options);
ManagementBaseObject descriptor =
outParamsMthd["Descriptor"] as ManagementBaseObject;
ManagementBaseObject[] dacl = descriptor["DACL"] as
ManagementBaseObject[];
foreach (ManagementBaseObject ace in dacl)
{
ManagementBaseObject trustee = ace["Trustee"] as
ManagementBaseObject;
string domain = (string)trustee["Domain"];
if ((string)trustee["Name"] == "Everyone")
{
UInt32 mask = (UInt32)ace["AccessMask"];
string enumMask = System.Enum.Format(typeof(Mask), mask, "g");
if (enumMask.Contains("WRITE"))
{
return true;
}
}
}
}
Thanks in advance
modified on Thursday, January 21, 2010 11:17 PM
|
|
|
|
|
I am sure this is an easy fix, I am not able to run any C# program, that i have compiled at home, on my work machine. I have previously been able to run them on other work computers but this one i cannot. It is a pretty crappy computer running XP. I am sure that it is just an update i am missing. It seems to have .Net 2.0. Can anyone help?
|
|
|
|
|
viciouskinid wrote: It seems to have .Net 2.0.
If you're not sure, you have to make sure. Navigate to C:\Windows\Microsoft.NET\Framework and look to for the folder names. Each will tell you which version of the framework is installed.
You also didn't say which version of Visual Studio you used to write your apps. If it's 2003, then you have to have .NET 1.1 installed. If 2005, .NET 2.0. If 2008, then it depends on your projects settings. 2008 can target 2.0, 3.0, and 3.5.
|
|
|
|