You question does not gives clarity about the device in which you are facing error. Its pen drive or SD card or you are talking about usage of cards using card reader. Any how let me explain you a standard set of methods which can be implemented on all the devices to remove the error.
Method 1 :- Removal of write protection error with the help of command prompt. Use most effective commands like diskpart along with regedit to repair the corrupted registries related to write feature.
Method 2 :- Scanning of SD card or Pen drive to remove all the available virus files from the devices. Removal will lead to repair of pen drive as well as SD card and error will stops coming now.
Method 3 :- Check Pen drive/ SD card restrictions by going into properties of it. Removal all the write restrictions in order to remove the error.
If you do not know actual practical process then you can take help of this video i am sharing below for your reference.