PDA

View Full Version : help with getting file???


halfasleeps
03-12-2008, 06:22 PM
I have this code:

var iconFile:File = File("C:/Documents%20and%20Settings/jisaacks/Desktop/autopro-7.exe");


which produces an error saying: Error #1034: Type Coercion failed: cannot convert "C:/Documents%20and%20Settings/jisaacks/Desktop/autopro-7.exe" to flash.filesystem.File.


I am confused what I am doing wrong. I typed the path into run> and it opened it just fine so I know that path is valid.

ABM
03-19-2008, 04:29 PM
Hi,

Deed you try it with other files, like jgp, gif etc.. and not.exe??

halfasleeps
03-22-2008, 12:13 AM
Hi,

Deed you try it with other files, like jgp, gif etc.. and not.exe??

No i didnt try that, I wil try it next time I am in the office and post back thr results.

Thanks!

halfasleeps
03-24-2008, 02:42 PM
OK I opened a new Flash CS3 air document and pasted put this in the timeline:


import flash.filesystem.*;

function createFile()
{
var desktopFile:File = File("file:///C:/Documents%20and%20Settings/jisaacks/Desktop/testfile.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(desktopFile, FileMode.UPDATE);
fileStream.close();
}

createFile();

and I get the same error.

but If I use File.desktopDirectory.resolvePath("testfile.txt");
it works and if I then output the file path it is exactly the same as the string I used above.

I dont want to have to use desktopDirectory though because I am trying to make a drag and drop feature, and a user can drag things from any file folder.



THANKS!!!