If you're wanting specifically to work with the eventlog, try using the System.Diagnostics.EventLog class. This will provide all of the writing methods you will need -- including writing an "error" event.
XRaheemX
Posts
-
Trace Question -
Load Balanced NetworkAs far as I know, load balancing is not done at the software application level. If NICs are load balanced they should automatically balance the traffice between the merged NICs. When you send traffic using .NET the load balancing should be auto handled.
-
Catching application start/close eventsWell, one way you could do this (which isn't the best way I don't imagine, but I can't think of any other way at the moment) is to create a task watcher process that watches the task list and kicks off event "alerts" that you set when certain tasks are created/exited.
-
Windows Search GifWhat!?
-
Disabling controlsUnfortunately for right now, if you're wanting to do real time text checks on the web page then some type of Client side script (such as Javascript) is your only option. The only way for the server to manage this is for the page to postback to the server every time the user presses a key in the textbox, which would keep them from typing more than say.. 3 words per minute.
-
Disaplying different panels from options in a dropdown listomg I'm so sorry... my mind was in VB.NET when I wrote this. (VB uses the keywork SELECT instead of SWITCH that is used in C#"
private void Speciality_SelectedIndexChanged(object sender, System.EventArgs e) { switch(Speciality.SelectedItem.Value.ToLower()) { case "breast surgery": SpecialityBreastSurgery.Visible = true; break; case "cardiology": SpecialityCardiology.Visible = true; break; default: //In case you want to do something "else" break; } }
Also remember that your strings for your CASE statements MUST be all lowercase in this instance because I used a .ToLower() in the switch. (I have a habit of doing this to remove casing errors). If you want to use exact case, just simply remove the .ToLower() from the switch.
-
Can u help? I need to save data from label to file on hard driveWell, for the simple one line of text in a file you won't need to parse anything. You can simply do just the opposite of what I have above. Check if the file exists but don't delete it. Instead of using File.CreateText you will use File.OpenText. Instead of using System.IO.TextWriter use a System.IO.TextReader. Instead of using WriteLine() use ReadLine(). It's all pretty simple. However, if you're putting multiple lines in the file for multiple objects/properties it does get a little more complex. A more simple way to do this would be to just serialize the label (or whatever other oject you have) into a file and deserialize it back from the file to an object in the code whenever you need it. A good example exists right here on code project: http://www.codeproject.com/csharp/objserial.asp[^]
-
XML SerializationWell silly, paste the new exception. It's probably a different exception than before. We'll work them out one by one.
-
DateTimePicker and Regional SettingUnfortunately I don't know of a fix, perhaps though you can band-aid it on the other side? When you retrieve the data back out, add 543 to it.
-
Can u help? I need to save data from label to file on hard driveI think it does currently but you can never tell what they might change in future releases. So I thought it'd be safe to go ahead and call it anyway.
-
Xbox 360 Development with the .NET Framework PetitionI'm completely with you 100%. I've been waiting to hear if they were going to do something in .NET so I could pursue a career in game dev. Where do I sign up?
-
Opening External ApplicationsSystem.Diagnostics.Process here is an example of running PING with some arguments:
using System.Diagnostics; public void RunPing() { Process p = new Process(); p.StartInfo.Arguments = "www.codeproject.com"; p.StartInfo.FileName = "ping.exe"; p.StartInfo.WindowStyle = ProcessWindowStyle.Normal; p.Start(); p.WaitForExit(5000); // Use this to pause the code until the application closes (this one times out and continues anyway after 5 seconds) }
-
Confusion on how Firewall worksNo offense to you, but you can probably get a better answer in a different forum than the c# forum. I'll do the best I can though: Firewalls allow the ability to restrict/allow on a URL name basis. Whoever set up your network probably has codeproject.* allowed.
-
Can u help? I need to save data from label to file on hard driveok.. a VERY simple example would be as such: (This is not at all the complete or best way to do it, just a simple example to start your building blocks)
public void WriteFile(string text, string fileName) { System.IO.TextWriter tw = null; try { if(System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); //Do this if you want to "overwrite" the file } tw = System.IO.File.CreateText(fileName); tw.WriteLine(text); } finally { if(tw != null) { tw.Flush(); tw.Close(); // Put these in the finally clause to make sure that the file closes } } }
-
Disaplying different panels from options in a dropdown listAlthough syntactically my code is correct, are you sure you are using a c# code behind and not a VB.NET code behind? Also, did you paste exactly what I wrote?
-
Can u help? I need to save data from label to file on hard driveHaha, I like to take time during my breaks an help people out ;) I'll catch up to them some day... when I'm older and wiser ;)
-
Can u help? I need to save data from label to file on hard driveThere are many many different ways to do this. I would research the System.IO.File and System.IO.TextReader and System.IO.TextWriter classes for more help. I could give you an example, but I don't think it would do any good unless we knew what exactly you're trying to do. It could be good as well to research Serialization as this is a nice easy way to Serialize and object to a file.
-
Properties in structuresYessir :laugh:
-
Properties in structuresAhhh.. I read right over that... Well, you can assign the property as long as you assign the field also. When building a struct constructor, the constructor must not exit until all fields have been assigned. Of course, you're thinking to yourself, "It does get assigned when the property is assigned"... unfortunately the compiler doesn't see that :(
-
Properties in structuresTry this:
struct MyStruct { int fieldx; public int Propertyx { get { return fieldx; } set { fieldx = value; } } public MyStruct(int i) { fieldx = i; } }