im trying to use Environment.CurrentDirectory with a public const string
public const string MsgPath = Environment.CurrentDirectory + @"values\messages.txt";
but it wont let me
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 28, 2013, 1:43 PM
The value of MsgPath depends on a call at run time to the method, Environment.CurrentDirectory, and so can't be declared 'const'.
However, you can declare it to be 'static readonly' which is just as good for most purposes:
pubic static readonly string MsgPath = Environment.CurrentDirectory + @"values\messages.txt";