Harto

Harto

  • NA
  • 67
  • 0

Getting the file extension.

Dec 9 2008 5:26 PM
I have this problem, consider working on a file called "this.is.a.test.only.txt"
- When the folder options is set to show the extensions of files, the dialog gets "txt" as the extension and which is ok.
- When the folder options is set to hide the extensions of known file types, the dialog gets "only" as the extension which is not what i want. As if it considers the last visible dot to be the one for the extension.
here is a part of the code where i'm experiencing the problem.

-------------------------------
private void btnTarget_Click(object sender, EventArgs e)
        {
            SaveFileDialog sdlg = new SaveFileDialog();
            sdlg.CheckPathExists = true;

                string fn = FileManager.GetRealFileName(this.txtOpen.Text);
                sdlg.Filter = " |*" + Path.GetExtension(fn);
                sdlg.DefaultExt = Path.GetExtension(fn);
                sdlg.FileName = fn;
        }
----------------------------------------------------

Is there any way where i can solve this one?
I appreciate your help

Answers (1)