kg has asked for the wisdom of the Perl Monks concerning the following question:
I encountered a problem using File::Util.
I am usingMy application has to be able to save files to arbitrary drives on my machine (no network drives). So far I can save files on the same drive the script is living in, but when it comes to saving on a different drive it fails:
File::Util can't use this string for »the name of a file or directory« +. »D:/projects/my_program/TestData/text.txt« It contains illegal characters.
I know that colons are illegal characters from the error message.
Is it possible to save files to drives other than the one my script is on an how do I
specify the path?
Can someone please help me?
Here is an example of what I am trying to do. The test application consists of two buttons only. One for selecting the directory, the other for saving the
file.
use strict; use warnings; use Tk; use File::Util; my $mw = MainWindow->new(); my $fh = File::Util->new(); my $directory = ""; my $browse_button = $mw->Button( -text => "Browse", -command => sub { $directory = $mw->chooseDirectory( -mustexist => "true", ), }, )->pack(); my $save_button = $mw->Button( -text => "Save", -command => sub { $fh->make_dir( $directory, qw /--if-not-exists/ ); $fh->write_file( file => sprintf( "%s/text.txt", $directory ), content => "hello world", ); }, )->pack(); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with saving files using File::Util on Windows
by kennethk (Abbot) on Dec 22, 2009 at 15:48 UTC | |
by kg (Acolyte) on Dec 23, 2009 at 11:07 UTC | |
by kennethk (Abbot) on Dec 23, 2009 at 15:16 UTC | |
|
Re: Problem with saving files using File::Util on Windows
by ikegami (Patriarch) on Dec 22, 2009 at 16:04 UTC |