Use File.applicationStorageDirectory.resolvePath("MyVideos/video_file.mp4");
instead of File.applicationStorageDirectory.resolvePath("file:///mnt/sdcard/MyVideos");
Due security violation issue so developer only can access ApplicationStorageDirectory without any security risk.
Also give filename MyVideos/video_file.mp4
instead of folder only MyVideos
.
var file:File=File.applicationStorageDirectory.resolvePath("MyVideos/video_file.mp4");
if(file.exists)
{
trace("file exists");
}
Like,
private function downloadComplete(event:Event):void
{
try
{
var file:File=File.applicationStorageDirectory.resolvePath("MyVideos/video_file.mp4");
var ba:ByteArray = event.target.data as ByteArray;
var fileStream:FileStream = new FileStream();
fileStream.addEventListener(IOErrorEvent.IO_ERROR,function(e:IOErrorEvent):void{
progressLabel.text = "File IO Error";
});
fileStream.open(file, FileMode.WRITE);
fileStream.writeBytes(ba);
fileStream.addEventListener(Event.COMPLETE, fileClosed);
fileStream.close();
progressLabel.text = "Download Sucessful";
trace(file.nativePath); //Where file actually stored
}
catch(eeee){
progressLabel.text = "Error";
}
}
When writing large files like Video/music file better use ASYNC mode
of writing/reading so your application works without UI freeze.