The chances are that when you were working in development, your code looked something like:
File.WriteAllText("MyTextFile.txt", "This is a line of text");
...
string data = File.ReadAllText("MyTextFile.txt");
which works fine - but it stores the file in the application folder which is readable and writable on your development machine, but when you try to do it in production, the application is stored under the "Program Files" folder which is not normally accessible to prevent viruses and worms fro tampering.
Instead, have a look here:
Where should I store my data?[
^] which explains safe places you can store data.