Q&A

Q1:What if I want to perform an operation on a file, but something is preventing the operation, such as the file may be open or I don't have rights to the file?
A1: All the method calls have one or more exceptions that can be thrown in the event that the method fails. These method calls are listed in the online Help. You can use the techniques discussed in Hour 16, “Debugging Your Code,” to trap the exceptions.
Q2:What if a user types a filename into one of the file dialog boxes, but the user doesn't include the extension?
A2: By default, both file dialog controls have their AddExtension properties set to true. When this property is set to true, C# automatically appends the extension of the currently selected filter.

Get Sams Teach Yourself C#™ in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.