I have been searching around for the best way to do this but haven't found
any solution. I need to check the columns in each row within a
DataGridView
to dtermine of it's Base64 encoded or not.
I would say some trial and error is your best bet. First, try running the
value through the Base64 decode process. If it's not valid Base64, you'll
get an error which you can trap.
In the event you get a "false positive," i.e., a string of characters which
happens to be legal Base64 even though the value wasn't actually Base64
encoded, you can examine the resulting bytes. Since I would guess you're
expecting normal ASCII values, anything less than 32 means it wasn't a
Base64 value. If you don't expect to have accented characters, you can add
"or greater than 127" to that test.
Ultimately, though, something can probably slip by, although I would think
the chances are low.