문제

I have a simple issue. I have a filedialog in a wpf application. Things works fine when I run the application for the first time. But when I change the file extension, and change back, I dont see anything.

This is the code:

Filedlg.FileName = "*.msr"; // Default file name
Filedlg.DefaultExt = ".msr"; // Default file extension
Filedlg.Filter = "Raw (.msr)| *.msr | All files |*.*" ; // Filter files by extension 

I see .msr files. Then I choose to see all files and then switch back to .msr extension. But I dont see any files.

Thoughts?

Kindly ask details if required.

도움이 되었습니까?

해결책 3

Filedlg.Filter = "Raw (.msr)|.msr|All Files(.)|.";

this one works. Problem was extra space between | All.

다른 팁

If you are using Filter property, DefaultExt gets ignored or in worst case can cause issues. You need to use FilterIndex instead to mark default extension. You can find out more here.

I would also skip setting file name to *.msr.

try this:

Filedlg.Filter =  "Raw (.msr)| *.msr |" + "All Files(*.*)|*.*";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top