public bool?ShowDialog()
        {
            var    openFileName = new OpenFileName();
            Window window       = Application.Current.Windows.OfType <Window>().Where(w => w.IsActive).FirstOrDefault();

            if (window != null)
            {
                var    wih  = new WindowInteropHelper(window);
                IntPtr hWnd = wih.Handle;
                openFileName.hwndOwner = hWnd;
            }

            openFileName.structSize   = Marshal.SizeOf(openFileName);
            openFileName.filter       = MakeFilterString(Filter);
            openFileName.filterIndex  = FilterIndex;
            openFileName.fileTitle    = new string(new char[64]);
            openFileName.maxFileTitle = openFileName.fileTitle.Length;
            openFileName.initialDir   = InitialDirectory;
            openFileName.title        = Title;
            openFileName.defExt       = DefaultExt;
            openFileName.structSize   = Marshal.SizeOf(openFileName);
            openFileName.flags       |= FOS.NOTESTFILECREATE | FOS.OVERWRITEPROMPT;
            if (RestoreDirectory)
            {
                openFileName.flags |= FOS.NOCHANGEDIR;
            }


            // lpstrFile
            // Pointer to a buffer used to store filenames.  When initializing the
            // dialog, this name is used as an initial value in the File Name edit
            // control.  When files are selected and the function returns, the buffer
            // contains the full path to every file selected.
            char[] chars = new char[FILEBUFSIZE];

            for (int i = 0; i < FileName.Length; i++)
            {
                chars[i] = FileName[i];
            }
            openFileName.file = new string(chars);
            // nMaxFile
            // Size of the lpstrFile buffer in number of Unicode characters.
            openFileName.maxFile = FILEBUFSIZE;

            if (LibWrap.GetSaveFileName(openFileName))
            {
                FileName = openFileName.file;
                return(true);
            }
            return(false);
        }
 public static extern bool GetSaveFileName([In, Out] OpenFileName ofn);