You can replace the Win32::FileOp part with the code below. I used several modules from whatever example code I found and quickly copy/pasted into my (Edit: original) reply. It was intended to show that there are a few options out there.
I tested this on 64 bit Strawberry Perl. (Edit: My previous post was tested on 32 bit Strawberry Perl.)
use strict;
use warnings;
use Win32::GUI();
my $startdir = 'C:\Users';
my $output_file = Win32::GUI::GetSaveFileName(
-title => "Save as...",
-directory => $startdir,
-file => "output.txt",
-filter => [
"Text documents (*.txt)" , "*.txt",
"All files" , "*.*",
],
);
if($output_file){
print("Using $output_file as output.");
}
else{
print("No output file chosen.");
}
I noticed that after I ran it once and chose a user directory it went to that same directory the next time. I assume it's a feature that it remembers. I found an option that seems to disable this kind of thing but haven't tried it. -nochangedir is 0 by default. It seems to be more to prevent the directory changing during the run so I'm surprised that the directory is remembered on the next run. Refer to http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=Reference-Methods for more detail and other options. |