0

I want to export a datawindow informations to a .txt file. When I click the export button the SaveAs Dialog Box opens. If a .txt document with the same name exists then a MessageBox pop-up questioning if I want to replace the file. If I press NO then SaveAs Dialog Box is closing. How can I prevent SaveAs Dialog Box from closing? I want to return in it and give another name to file.

Here is my code:

li_rc = GetFileSaveName  (lcs_title, ls_path_filename, ls_filename, 'txt', 'TXT File (*.txt), *.txt' )
        
        if li_rc > 0 then
            if FileExists (ls_path_filename) then
                //Existing file has been found
                if MessageBox (lcs_title, 'Replace the file '+ ls_path_filename +'?', Question!, YesNo!, 1) = 2 then
                        //Do not replace the file
                        //Return to dialog?
                    else
                        //Replace the file
                        dw_1.SaveAs(ls_path_filename, Text!, false)
                end if
            end if      
         end if 

Thanks!

XLD_a
  • 195
  • 1
  • 4
  • 16

1 Answers1

0

Try this

boolean lb_need_file = true

do while lb_need_file

    li_rc = GetFileSaveName  (lcs_title, ls_path_filename, ls_filename, 'txt', 'TXT File (*.txt), *.txt' )
        
    if li_rc > 0 then
        if FileExists (ls_path_filename) then
            //Existing file has been found
            if MessageBox (lcs_title, 'Replace the file '+ ls_path_filename +'?', Question!, YesNo!, 1) = 2 then
                    //Do not replace the file
                    //Return to dialog?
                else
                    lb_need_file = false
                    //Replace the file
                    dw_1.SaveAs(ls_path_filename, Text!, false)
            end if
        end if      
     end if 
loop

Please let us know if this works for you

Eric Glenn
  • 389
  • 2
  • 12