|
1. That depends on what you mean.
A RegEx can for instance create a collection of match objects, where each match contains a collection of Group objects, which all contains a copy of part of the string.
2. There are many ways of extracting information using Regex. Here is a piece of code that I used just recently:
return Regex.Match(_message, "\r\nPage: (.*?)\r\n").Groups[1].Value;
It finds a line that starts with "Page: " and gets the rest of the line.
---
b { font-weight: normal; }
|
|
|
|
|
You can use Regex as a more heavy duty way of getting substrings.
The following code will replace whole words wich starts with the letter P.
in the provided example strOnj would end up equalling "Some Sentence to be seperated"
string strObj = "Some Sentence to Parse";
strObj =Regex.Replace(strObj,"P[a-zA-Z]+"," be seperated");
|
|
|
|
|
hi
i want to create trial version from my app and after it was Expired, end user can't restore windows and use it again. How to do ?
thanks ..
|
|
|
|
|
You can add an entry in the registry which consists of the date of installation and the expiry date.
You can check this value when the app starts if the date has reached just delete the registry entry and the app should not be executed if the registry entry is not present.
Hope that works for u.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
The registry entry will have to be created every time you install the application, so after expiration you'll just have to reinstall to get another trial period.
It'll also be saved if you create an image of your windows after installation.
And there are tools out there that can easily track all modifications done to the registry so you can see which registry key is being created.
I'm afraid there is no really watertight way to achieve this when only a single computer is concerned (i.e. without some sort of online activation).
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
If you dont mind using a commercial tool, take a look at CryptoLicensing
It can limit licenses to N number of days.
|
|
|
|
|
I create a class file dynamically and save it on the file system in a class.cs file.
How can I load that file as a class object and bind it to PropertyGrid?
Thanks.
|
|
|
|
|
You'll have to dynamically compile your generated class file (take a look at the Microsoft.CSharp and System.CodeDom.Compiler namespace), load the generated assembly and create an object of your class using Activator class.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I guess you would have to compile the class into an assembly first. Then load the compiled assembly and create an instance of the class and then bind it to the propertygrid.
If you need details, just ask.
|
|
|
|
|
I need details please .
|
|
|
|
|
I can not figure out why the Page_Load is fired twice. Searched every where. Microsoft support says bug with smartnav but we are not using smartNavigation.
Can anybody help me resolve this mystery.
Thanks
-- modified at 17:36 Thursday 12th October, 2006
|
|
|
|
|
Doing any Server.Transfers or such within the page that you might be redirecting back to itself .
I would actually step through the breakpoint of the Page_Load as it enters it for the first time. From there, see where it goes...it might be there is something in your code producing your problem.
|
|
|
|
|
I've written a Service. OnStarts starts a new Thread which will periodically perform some action. Everything works as expected. The only problem is, that the action which should be performed is, goes like this:
ProcessStartInfo psi = new ProcessStartInfo(sFilePath, sArguments);
try
{
Process.Start(psi);
}
catch (Exception e)
{
}
Something goes wrong here, because the process is not started and an exception is not thrown either. Can somebody please tell me why? Does it have to do something with the service interacting with the desktop? If so, how can I allow this programatically?
I hate to say it, but it is urgent...
Thanks a truckload in advance!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
Well, a windows service runs under the 'System' user account. It could be related to that. My best suggestion is to startup the service and then attach to the process using Visual Studio and debug it. Just remember to build the debug version of the service, install it, and start it.
It can be found from 'Debug' -> 'Attach to Process'.
or you can include this line into your code right before you start the process.
System.Diagnostics.Debugger.Launch();
That should do it.
|
|
|
|
|
hi andrew,
first of all, thanks for your reply. I've attached the debugger. here is what I found out so far: the process is actually started but not visible for some reason. I can see it in the task manager. I guess it has something to do with allowing a service to interact with the desktop. I'm gonna google on this one.
If somebody knows how to allow a service to interact with the desktop, please let me know.
many thanks in advance!
/matthias
I love deadlines. I like the whooshing sound they make as they fly by. [Douglas Adams]
|
|
|
|
|
There was actually a question just a few threads below yours that asked that very same question.
http://www.codeproject.com/script/comments/forums.asp?msg=1709786&forumid=1649#xx1709786xx[^]
Though, I would suggest allowing the service to interact with the desktop as it would be a security hole. Using remoting or some other form of interprocess communication would be best...
I would almost suggest an old school approach to having a process running in the background for a user - the startup menu. You could have the process started when the user logs in and begin minimized (use a parameter for such) and remain in the icon tray. From there, the process would be able to poll events and interact with the user with less risk of security issues.
Just a thought. Good luck.
|
|
|
|
|
hi all,
please help me with this.
i am not able to get the selected value in a dropdown list
DataSet dsLoadDDLState=new DataSet();
dsLoadDDLState=objContactDetails.LoadState();
ddlState.DataSource=dsLoadDDLState.Tables[0];
ddlState.DataMember="State_Id";
ddlState.DataValueField="State_Name";
ddlState.DataBind();
string str=ddlState.SelectedValue;
|
|
|
|
|
What happens when you run the supplied code? just looking at it quickly without the rest of the code, it looks like str would alwyas equal the default selected value. If im not mistaken you would need to use the 'SelectedIndexChanged' event so that when you made a choice then str would be assigned the value clicked
|
|
|
|
|
Can someone please explain why one is correct/better or incorrect/worse?
public class Gatorade
{
public Gatorade(){}
private ArrayList _Ingrediants = null;
public ArrayList Ingrediants
{
get
{
if (_Ingrediants == null)
{
_Ingrediants = new ArrayList();
}
return _Ingrediants;
}
set { _Ingrediants = value;}
}
public void IngrediantsList()
{
_Ingrediants = new ArrayList();
this._Ingrediants.Add("Water");
this._Ingrediants.Add("Sucrose Syrup");
this.Ingrediants.Add("Water");
this.Ingrediants.Add("Sucrose Syrup");
}
}
If I do this.Ingrediants.Add("Water"); then I dont have to manually instantiate _Ingrediants but this way I am accessing the public property. Please advice. Thanks.
|
|
|
|
|
robert110 wrote: public ArrayList Ingrediants
In most cases you don't whant to do:
public ArrayList Ingrediants
To initialize the object:
private ArrayList _Ingrediants = new ArrayList();
To expose contents of the list publicly use IEnumeration or IList or something rather than returning the reference to the list.
led mike
|
|
|
|
|
robert110 wrote: public void IngrediantsList() { /* Should I Do This */ _Ingrediants = new ArrayList(); this._Ingrediants.Add("Water"); this._Ingrediants.Add("Sucrose Syrup"); /* Or This: */ this.Ingrediants.Add("Water"); this.Ingrediants.Add("Sucrose Syrup"); }
I would rather code like this:
public Gatorade()
{
_Ingrediants = new ArrayList(0);
}
public ArrayList Ingrediants
{
get
{
if (_Ingrediants.Count == 0)
{
this.IngrediantsList();
}
return _Ingrediants;
}
}
private void IngrediantsList()
{
this._Ingrediants.Add("Water");
this._Ingrediants.Add("Sucrose Syrup");
}
of course _Ingredients is a private variable. Do not expose method when it is not necessary. Follow good encapsulation.
|
|
|
|
|
i need to create a font property to a control that i have created ,
can someone help me ?
|
|
|
|
|
Hello,
I think you have to pick one of these possibilities.
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
private Font _font;
public new Font Font
{
get
{
return _font;
}
set
{
_font = value;
}
}
public new Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
}
}
private Font _myfont;
public Font MyFont
{
get
{
return myfont;
}
set
{
myfont = value;
}
}
Hope you found youre solution!
All the best,
Martin
|
|
|
|
|
Hi!
I have a textfile which contains Name and Value (each name has a value). I want to display ONLY the names in a listbox. And it should be the names with the 10 highest scores. The highest score first...
I do know how to fill the listbox with all the names. But I cant get around to the other...any suggestions?
Newbie untill I die!
|
|
|
|
|
Show us how your txt is formatted
If it's something like "name=value" then you could do something like that
a) string[] lines = File.ReadAllLines("highscores.txt")
b) create a class:
struct Highscore
{
public string name;
public int score;
}
b)
List<Highscore> scores = new List<Highscore>();
foreach line in lines {
Highscore h = new Highscore();
h.name = line.Substring(0, line.IndexOf('='));
h.score = int.Parse(line.Substring(line.IndexOf('=')+1));
scores.Add(h);
}
c)
scores.Sort(... some IComparer to sort for score ...)
d)
for(int i=0; i<10; i++)
listbox.Add(scores[i].name);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|