I think somebody recommended for me to use Photorec once on a wonky memory card. I think it worked. I think that one is a Windows program. I also seem to remember ddrescue for Linux, and a few variants on that. Maybe gddrescue. Not sure about that one. It's been a long time. Obviously, on this forum, you can try a SpinRite Level 2 on the card if you can get it into a card reader that SR can talk to. Also, try a different card reader and a different cable if one generates failures. As
@Steve has pointed out, running a Level 2 SpinRite on memory devices a couple of times a year has therapeutic value. That's harder to do on a bunch of memory cards than it is for hard drives. And it's hard to track that for hard drives. See my burn in procedure below. Windows CHKDISK may not be the best thing to start off with for data recovery since it will orphan any erroneous files it finds.
No idea what to do if your card is counterfeit. There may be nothing you can do.
Here are some thoughts for problem prevention with new cards. Buy name brand cards. I like Samsung. I think Sandisk is good, and Kingston, and Patriot. It's been a while since I studied the market, and I don't know who's bought whom. If you're going to be hitting the card with lots of writes (like in a Raspberry Pi), go for the extreme endurance or pro version. If it's a major maker which is reputable, look for a 2 year, 3 year, or 5 year warranty. Buy your cards from a reputable brick and mortar vendor, even if by mail. I've started shying away from buying memory cards and batteries on Amazon or Ebay. Sometimes things from those sources are counterfeit. It's a big problem. Sometimes they are returned and resold. I don't ever want a USED memory storage device. Sources I would gravitate toward include Best Buy, Target, Walmart, Office Max / Office Depot, Staples, Adorama, B & H Photo, etc.
This is easy to say, hard to do. Don't trust memory cards. I used to teach electronics at DeVry University. I told my students don't trust memory cards and memory sticks. Have a backup of your content. Caveat, even now, though, I have some photos on camera's that I haven't moved off. When I do move them off to my PC, they get backed up online that evening with JungleDisk via AWS that
@Steve mentioned years ago. I don't necessarily recommend that for new users, but I'm still using it.
I like to burn in memory devices including memory cards, USB sticks, and SSD's before trusting them. The trouble I go to increases with the amount of data storage. At a minimum, I'm going to format the card and run a Windows CHKDISK on it. You can do this by right clicking on the card in Windows File Explorer (at least in Windows 7), properties, tools, check for errors. UNCHECK the automatically fix errors box and CHECK the search for bad sectors box. This makes sure each sector is read. This process is NON DESTRUCTIVE, and can be used with a card with data. As the instructions in SpinRite say for Level 2, this "brings the drive's attention to each sector" and alerts the controller to any anomalies it doesn't like. A SpinRite Level 2 would do something similar, but would try to correct errors. Hopefully there are none for a new card. The reason I uncheck the automatically fix errors box is that this tends to orphan files which are found to be in error.
By the way, you don't HAVE to format big cards with EXFAT. If you want to use a card with Linux for example, you can format with NTFS or FAT32. You may wish to use FAT32 for Android devices. You may have to use an external utility to do so. Make sure it's reputable. This article talks about that.
Can I format the SD card to NTFS on Android? Should you format the SD card to NTFS or FAT32 for use on an Android phone? Follow this guide and learn how to format SD card to NTFS on PC and Android devices successfully.
www.easeus.com
If the card is bigger, say over 32 GB or 64 GB, I go to a bit more trouble. I will do a SpinRite Level 4 on it. Yes, I said Level 4. It will read, invert, write, read, invert, write the card. Yes it uses up 2 full write cycles. But, then I know every memory cell has been thoroughly tested and the controller should have reset all it's magic error correction. Before the SpinRite, I fill the device with random data. In that case, it uses 3 write cycles. See below. If doing SpinRite is not practical, IE rebooting with a card reader on a port that works, I have an alternative method.
Years ago, I wanted to do some of this type of testing on a HDD. But, it works for SSD's and memory devices too. I Googled something like generate file with random data. I get pages such as this for Linux:
How can I create a new file and fill it with 1 Gigabyte worth of random data? I need this to test some software. I would prefer to use /dev/random or /dev/urandom.
unix.stackexchange.com
And commands such as this:
dd if=/dev/urandom of=target-file bs=1M count=1000
I don't remember exactly what I did years ago. But, it was similar to that. That command will generate an output file with 1 GB of random data. By changing the count, I generated files of 1 MB, 2 MB, 4 MB, 8 MB, 16 MB, 32 MB, 64 MB, 128 MB, 256 MB, 512 MB, 1 GB, 2 GB, 4 GB, and 8 GB. I keep them hanging around on my PC for when I want to do testing of storage devices. So, I would copy as many of these as I can to the memory card, USB stick, SSD, or even HDD to fill it up completely. For what it's worth, I just did this to a 2 TB SSD. Took a while. If you highlight all the random data files in Windows Explorer, select copy, then paste them into the memory card, Windows will offer to rename them as many times as necessary to make the copies. Just keep doing this over and over. Note that a 32 GB card, for example, won't have 32 GB of available space after formatting. So, I couldn't just copy 4 of the 8 GB files. Once the card is full of random data, I run the CHKDISK on it with the search for bad sectors box turned on. As an alternative, you can run SpinRite Level 2 or Level 4 after storing the data. A fill with data procedure plus a SpinRite Level 2 will only use up one write cycle. A fill with data procedure plus a SpinRite Level 4 will use up 3 write cycles.
Crossing my fingers so as to not jinx myself. Using these procedures, I rarely have failed memory cards. But wait, there's more. As mentioned above, you should run a SpinRite Level 2 or this CHKDISK search for bad sectors a couple of times per year. A solid state memory device can leak away it's data within a year if it's never powered on and allowed to do it's housekeeping. After testing, erase most or all the random data AND empty the trash if it's relevant for such devices on your PC. Initial writes to the card may be slow until its controller has had a chance to do the block erases necessary to write new data. Always try to leave at least 10 % of a memory device empty so it can do housekeeping. Once you're through testing, you may wish to format the card in the camera or whatever you want to use it in just to make sure that device is happy.
Hope you find this info useful.
May your bits be stable and your interfaces be fast.

Ron