Troubleshooting: Reading from and Writing to Text Files (Visual Basic)
This topic discusses common problems encountered when working with text files and suggests an approach to each.
The most common issues encountered when working with text files include security exceptions, file encodings, or invalid paths.
A SecurityException is thrown when a security error occurs. This is often a result of the user lacking necessary permissions, which may be solved by adding permissions or working with files in isolated storage. For more information, see Troubleshooting Exceptions: System.Security.SecurityException.
File encodings, also known as character encodings, specify how to represent characters when text processing. Unexpected characters in a text file may result from incorrect encoding. For most files, one encoding may be preferable over another in terms of which language characters it can or cannot handle, although Unicode is usually preferred. For more information, see File Encodings (Visual Basic) and Encoding.