Help on file open dialogue

Mar 7, 2012 at 4:11 PM

Hello

I need help to make two file open dialogues open only selected file types.

I use string properties with 

FilePath(".txt")

, but the default extension doesn't seem to do the trick. I've tried using a .txt filter as well.

Coordinator
Mar 7, 2012 at 6:39 PM

This should be correct, can you set a breakpoint in the FilePicker.Browse method and check if the DefaultExtension is passed correctly?

Mar 7, 2012 at 9:24 PM

I'm not sure what you mean, could you specify?

I use the PropertyTools version from NuGet. Basically, what I have is:

		[FilePath(".txt"), other annotations...]
		public string MyFilePathProperty { getset; }
Coordinator
Mar 7, 2012 at 9:42 PM

You need to get the source code to be able to debug the FilePicker control.

The TestFilePathAttribute example in the PropertyControlDemo seems to work.

See also http://msdn.microsoft.com/en-us/library/microsoft.win32.filedialog.defaultext.aspx ("If the extension cannot be determined from the Filter property, DefaultExt will be used instead.")

The AddExtension property is true (default) in the file dialogs.

Mar 8, 2012 at 12:08 PM

It works when you make a filter. This works:

[FilePath("Text file |*.txt"".txt")]