error compiling for board

Hello, recently I bought an arduino mega clone online and it was working perfectly but for the past two days i was getting this error

Arduino: 1.8.0 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

d:\arduino stuff\arduino\hardware\tools\avr\bin../lib/gcc/avr/4.9.2/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: Permission denied

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I tried many ways to resolve this like reinstalling the arduino ide ,restarting my laptop,installing a new driver and so on...

I would really appreciate if someone could help me solve this problem.

I suspect the Arduino15 directory.

A bunch of people have had IDE 1.6.x (and now 1.8.x?) problems, including IDE crashes and bizarre compile errors, when they had a previous 1.5.x/1.6.x installation. At least some of those problems seem to be caused by incompatible executables and preference files that the IDE saves outside the IDE installation directory. Perhaps that is what is causing your particular problem. In such cases it appears that the fix is to delete or rename the old "Arduino15" directory and re-install 1.6.x.

On Mac OS X:
/Users/(username)/Library/Arduino15 (a.k.a. ~/Library/Arduino15)
(Note: The 'Library' folder is greyed out in Finder. The folder can't be opened with a double-click. To browse the contents of 'Library', ctrl-click on it and select "Open in New Tab" from the pop-up menu.)

On Windows delete or rename both:
Arduino IDE 1.6.5r5 and previous: C:\Users(username)\AppData\Roaming\Arduino15
Arduino IDE 1.6.6 and later: C:\Users(username)\AppData\Local\Arduino15

On Linux:
/home/(username)/.arduino15 (a.k.a. ~/.arduino15)
(Note: file/folder names starting with '.' are not normally shown in directory listings. Use 'ls -a' to get a directory listing that includes the hidden files.)