i am using the common file dialog. i think there will be many things i need to know and validate eg. file type, file exists, not enough memory etc.
for file type, can i limit file types that can be opened using open file dialog? filter seems to still allow the user to type in a file with a different filetype. must i validate in code?
can i say that just by setting CheckFileExists = True, i should not need to check again in code the file exists?
is there a need to validate if there is a OutOfMemoryException? i am thinking, if all i should be opening is small files, i can get away with not handling that? not a good practice i guess?
are there any others i missed out?
Yes, you need to validate that a file selected with
OpenFileDialogexists and is of correct type as these cannot be enforced. As far asOutOfMemoryExceptionis concerned I am afraid there’s no reliable way to test if it will occur. Even if you try to see available memory and verify that this number is greater than the file size an exception could still occur later when you try to read the file because the garbage collector or some other process might have changed this.