Question

I have tried searching for this problem without any luck so I do apologise if something like this has been asked before!

I have a WCF Service that monitors File Changes in a Folder Path set by a value in a remote database.

The theory is that I will be able to:

1) Install the service and it will add itself as a 'client' in the database with an ID and Name

2) I will then be able to add Folders for that Service to monitor

I am struggling at the moment where to set a name or unique identifier that will not conflict or change on reboot?

Only current solution I can think of is manually setting the value in app-config on each build, but this would obviously take away the ability to just install 20 clients on 20 machines for quick testing.

Any advice appreciated, kind of banging my head against a wall at the moment.

Thanks!

Was it helpful?

Solution

Problem solved,

I managed to find a way to permanently store the persistent string in app.config. The way I was working with it before meant that it was not 'saving'

Code updated:

 static void Main(string[] args)
{
    SaveString("dbuniquename", (System.Guid.NewGuid().ToString());
}

That goes in my main and

private static void SaveString(string key, string value)
{
    Configuration config= ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    config.AppSettings.Settings[key].Value = value;
    config.Save();

    ConfigurationManager.RefreshSection("appSettings");
}

As the function to save.

Just listing in case anyone else had a troubles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top