[Solved] Which value should I assign to OpenFileDialog.FileName? [closed]


A quick primer on OpenFileDialog:

You almost never assign a value to FileName, as this value is the path to the file the user selected. You can use it to pre-populate the file name, but if the file doesn’t exist in the start folder, it may well revert to String.Empty (the behavior you described). The first assignment you do has nothing to do with the file dialog, so of course it will always succeed.

What it looks like you are trying to do is set the filter string to word documents, which you do by setting the filter property like so:

openFd.Filter = "Word Documents|*.doc"

You can read more about the Open file dialog on MSDN.

Please let me know if I can clarify anything!

2

solved Which value should I assign to OpenFileDialog.FileName? [closed]