本文介绍了将图像保存在 applicationStorageDirectory 的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将图像文件保存到我的 air 项目的 applicationStorageDirectory 中的目录中.先创建目录
I was trying to save an imagefile to a directory in applicationStorageDirectory of my air project. Created the directory first
var imageDirectory:File = File.applicationStorageDirectory.resolvePath("vispics");
if (imageDirectory.exists)
{
Alert.show("Directory Already Exists");
}
else {
imageDirectory.createDirectory();
Alert.show(imageDirectory.nativePath);
}
下一部分是从我的 cam 中保存图像,现在它会保存到 applicationStorageDirectory.这是我的做法
The next part is saving image from my cam right now it saves to the applicationStorageDirectory. Here is how i do it
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"目录中?提前致谢.
Is there a way that i can store the image in my "vispics" directory?Thanks in advance.
推荐答案
尝试:
var file:File = File.applicationStorageDirectory.resolvePath("vispics/" + filename);
这篇关于将图像保存在 applicationStorageDirectory 的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!