applicationStorageDirectory

applicationStorageDirectory

本文介绍了将图像保存在applicationStorageDirectory的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将图像文件保存到我的航空项目的applicationStorageDirectory目录中。首先创建目录

  var imageDirectory:File = File.applicationStorageDirectory.resolvePath(vispics); 

if(imageDirectory.exists)
{
Alert.show(目录已经存在);

}
else {
imageDirectory.createDirectory();
Alert.show(imageDirectory.nativePath);

$ / code>

下一部分是从我的cam中保存图像,现在保存到applicationStorageDirectory 。这里是我怎么做的
$ b $ pre $ 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目录中?
在此先感谢。

解决方案

试试:

  var file:File = File.applicationStorageDirectory.resolvePath(vispics /+ filename); 


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);
   }

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();

Is there a way that i can store the image in my "vispics" directory?Thanks in advance.

解决方案

Try:

var file:File = File.applicationStorageDirectory.resolvePath("vispics/" + filename);

这篇关于将图像保存在applicationStorageDirectory的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-15 19:55