Hi - I have a small monitoring application I want to change to a windows service (was a form).
Is there any way I can declare a variable (a string) which I can set when the windows service runs - and which I can retrieve again, next time the windows service runs?
Thanks, Mark
Loading
Kirtan PatelPosted Aug 13, 2009, 1:54 PM
You can Set Variable like that in Windows Service Also that can be Retrived Again when you Run Service Again
Just add Variable From
Project > Properties > Settings
you can Create Setting Variables As many as you want
Use in your Code like Below
//set Its Value Like below code
Properties.Settings.Default.Testvar = "This is Test Var";
Properties.Settings.Default.Save();
// Get Its Value
string var = Properties.Settings.Default.Testvar;
Happy Coding :)
MarkPosted Aug 13, 2009, 5:47 PM
Master BillaPosted Aug 13, 2009, 1:44 PM
yes you can define in form application also
Just take my simple code , only has variable declaration in init point in windows form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using System.Drawing.Printing;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string mylocalV = "Test";
}
}
}
Thank you