TonyLewis-2057 avatar image
0 Votes"
TonyLewis-2057 asked XingyuZhao-MSFT commented

VB.NET determine if a file is ASCII text before opening?

One can select a file via OpenFileDialog, and set the file filters to .TXT or other extensions to limit input files to text based files. However, it is possible to have an ASCII text file that has no extension, or the wrong extension. Likewise, binary files can have .txt or other file extensions when they are not text based.

Is there a way to check a file when selected and determine if its contents are ASCII text based before (or after) the file contents are read?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @TonyLewis-2057 ,
ASCII is a subset of UTF-8, and it can be identified by the lack of bytes in the 80-FF range.
Here's a reference you can refer to:
Effective way to find any file's Encoding
Hope it could be helpful.

0 Votes 0 ·

0 Answers