I have no idea if this actually would work, but something like this?
private var origUrl:String
private function saveFile():void
{
var f:File = new File();
origUrl = f.url;
f.addeventlistener(Event.SELECT,onfileselected)
f.browseForSave(blah);
}
private function onfileselected(event:Event)
{
var f:File = event.target as File;
// compare f.url with origUrl to get some sort of relative path in order to
escape the path delimiters and save it as a file.
}
Sorry, I'm just off to bed or I'd run it up, but would be interested to know if
it does work at all. Thanks!
putting a / in a filename, no matter how it's rendered by the OS seems pretty
stupid to me, however.
-Original Message-
From: flexcoders@yahoogroups.com on behalf of seanmcmonahan
Sent: Tue 1/19/2010 7:04 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Escaping slashes in a file name in AIR
So this is a problem that's not really a problem yet it is. I think it's best
explained with an example:
A user wants to save a file so we open the save dialog box via
File.browseForSave(). User then selects a folder my folder and types in a
name like my/file/with/slashes.txt and hits the save button.
What happens is AIR interprets this as save a file slashes.txt in the folder
my folder/my/file/with. To me this seems perfectly reasonable and correct.
In fact, I would say this IS the correct behavior. However my users feel that
what should happen is that a file with the name my/file/with/slashes.txt
should be saved out in my folder.
I haven't tested on Windows but on Mac OS using Safari and Chrome the user's
expected behavior is what happens. In Firefox the slashes are converted to
underscores. This leads me to believe that these browsers are all getting the
name back and escaping the slashes.
In AIR I'm not seeing anyway to get the filename and escape it as the select
that is fired when the user clicks save returns a File object with a name
property set to slashes.txt -- that is, whatever is after the last slash.
Does anyone know how to capture the filename and escape slashes or is that just
not going to happen?
__
This communication is from Primal Pictures Ltd., a company registered in
England and Wales with registration No. 02622298 and registered office: 4th
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT
registration No. 648874577.
This e-mail is confidential and may be privileged. It may be read, copied and
used only by the intended recipient. If you have received it in error, please
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637
1010. Please then delete the e-mail and do not disclose its contents to any
person.
This email has been scanned for Primal Pictures by the MessageLabs Email
Security System.
__winmail.dat