I’m a bit new to VB.NET. I was wondering if there was a way to detect if a file being open doesn’t exist, then something will happen. Is this possible and is it possible using the “If” statement?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
file.exists(filename)to check before you open it, or a try-catch block:or
You can add
imports system.ioat the top of your file to useFile.Existsinstead ofSystem.IO.File.Exists.