我试图将图像文件保存到我的air项目的applicationStorageDirectory中的目录中。首先创建目录
var imageDirectory:File = File.applicationStorageDirectory.resolvePath("vispics");
if (imageDirectory.exists)
{
Alert.show("Directory Already Exists");
}
else {
imageDirectory.createDirectory();
Alert.show(imageDirectory.nativePath);
}
下一部分是从我的摄像头保存图像,现在它保存到applicationStorageDirectory。我是怎么做的
var randInt:int = Math.random() * (99999 - 1001) + 1001;
var randStr:String = randInt.toString();
var filename:String = ""+randStr+".jpg";
var file:File = File.applicationStorageDirectory.resolvePath( filename );
var wr:File = new File( file.nativePath );
var stream:FileStream = new FileStream();
stream.open( wr , FileMode.WRITE);
stream.writeBytes ( imageData, 0,imageData.length );
stream.close();
有没有办法可以将图像存储在我的“vispics”目录中? 提前谢谢。
答案 0 :(得分:2)
尝试:
var file:File = File.applicationStorageDirectory.resolvePath("vispics/" + filename);