PDA

View Full Version : file extentions


corbo950
07-03-2008, 03:46 PM
is there away to set the file extension when saving a file out of an AIR application?

evride
07-03-2008, 10:39 PM
you can do so in the resolvePath() function.


var file:File = File.desktopDirectory.resolvePath("image.jpg");
trace(file.type); // this will get you the file extension and this is a read only property, cannot set.


http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/filesystem/File.html#propertySummary

johnnyboy
07-06-2008, 10:56 PM
Hey man,

Were u thinking about actually changing the format of a file or?

Let's say you load in a JPG, you could convert it and save it as a PNG via BitmapData and the adobe image encoder classes.

Just a thought, if that was ur interest :)

corbo950
07-25-2008, 02:38 AM
no i was just am having people export a csv file and didnt want them to have to type in .csv and i got it set

OrganicChem
02-24-2011, 01:35 PM
Hello,

My first post on this forum. I have a similar situation in my Air program where I need to have the user save the file in a specific location with a specific name natively. The default extension is .pdf but if they change the file's name and don't add the .pdf extension, silly Adobe won't recognize this as a pdf file and all hell breaks loose. This happens only in Windows environment. I wish someone can help me out there, my function to call the save:


public function mergeComplete(outputFile:File) : void {

PopUpManager.removePopUp(processingPopup);

var byteArray:ByteArray = new ByteArray();

var fileStream:FileStream = new FileStream();
fileStream.open(outputFile, FileMode.READ);
fileStream.readBytes(byteArray);
fileStream.close();

outputLocation.addEventListener(Event.SELECT, selectHandler);
outputLocation.save(byteArray, "myFile.pdf");

}



Thanks, I await some responses.