If it were possible to edit what is inside program files without permission it would be a huge security breach, which I recommend at least is you use the user level folder, but for each user will be generated a . txt (depends on what you have already done and need):
var pathArqFinal = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\Filename.txt";
According to microsoft website: https://docs.microsoft.com/pt-br/dotnet/api/system.environment.specialfolder?view=netframework-4.8
The directory that serves as a common repository for app-specific data for the current mobile user. A mobile user works on more than one computer on a network. A mobile user’s profile is maintained on a server on the network and is loaded into a system when the user logs on.
If it is for all users could use the CommonApplicationData
, thus:
var pathArqFinal = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\Filename.txt";
The directory that serves as a common repository for application-specific data that is used by all users.
This way it will be a file used by all, the problem is that you will need to be careful with "race condition", because multiple instances of the application may get tangled when recording.
Check if the problem occurs when you open the application as an administrator.
– CypherPotato
If opening as administrator does not occur, runs perfectly. As I make it permanent, without having to run every time as administrator?
– Raimundo
You have to run as an administrator if the folder is progamma files.
– Andrew Alex