I am trying to create a TXT file using the system.io, i put in the file path but every time i run it my access is denied , to every folder i C: , in DISK D:everything is fine, is there a solution to it , by a solution i mean , can i get access to it somehow in the code?
the code i used:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Windows.Forms;
using System.IO;
namespace KeyLoggerA1
{
    class Program
    {
        private static int WH_KEYBOARD_LL = 13; //hook procedure type , monitoring low-level keyboard input events
        private static int WM_KEYDOWN = 0x0100;
        private static IntPtr hook = IntPtr.Zero;
        private static LowLevelKeyboardProc llkProcedure = HookCallback;
        static void Main(string[] args)
        {
            string filePath = @"C:\Program Files\Test.txt";
            if (!File.Exists(filePath))
            {
                using (StreamWriter sw = File.CreateText(filePath))
                {
                    sw.WriteLine("test");
                }
            }
the error i am getting:
Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'C:\Program Files\Test.txt' is denied. ... at System.IO.File.CreateText(String path) at KeyLoggerA1.Program.Main(String[] args) in C:\Users\mirer\source\repos\ConsoleApp2\ConsoleApp2\Program.cs:line 28
If Anyone can help it will be appreciated
 
     
     
    