how to know the folder as write permission in air application..in my application i am saving txt file in folder,so that i need to test that folder as write permission...
var file:File = File.desktopDirectory.resolvePath("TxtFolder/DataFile.txt");
i need to check "TxtFolder" has write permission...? before saving the file(DataFile.txt)..how can i do it in flex Air as3
Thanks In Advance...
You can handle ioError event which FileReference dispatches when you don't have permissions to write into directory.
Run the AIR app as administrator and you can even write inside system32 folder of windows. That means anywhere, just anywhere.
You can write to a file with AIR only if the file is under "applicationStorageDirectory".
This is the only folder that has write permision.
If some know more please correct me.
Related
Hi I already posted a question Qt WinRT App cannot access file permission denied regarding ffmpeg library and video file read, and now I think the entire project should have some permission to access/modify the files system in WinRt Qt App.
Below is a simple code which create a directory if not exist, bu this also failing always, so I think it permission issue, and there are something should add on AppxManifest.xml.
QString dirname = QDir::homePath()+"/test";
QDir dir(dirname);
if(!dir.exists())
{
//dir.mkdir(dirname);
if(false==dir.mkpath(dirname)){
qDebug()<<"Creating "<<dirname<<" failed...";
}
}
Anyone have faces this before, any suggestion, tips ..
Thanks in Advance.
Haris
WinRT as a platform will not allow you to "simply" create files outside the sandbox of the application. There are certain directories you can use (Media, Photos, ...) in case you have the correct capability set. And even then you will only be allowed to open/create/read/write files selected by the file picker.
I can write to db when running in IDE(FB), while after packaging a air, the app wont write to sqlite db, Why? Thanks in advance.
The likely cause is that your installed Air application can't resolve the path to your sqlite file.
What I normally do is to use one of the static public properties of the File class to resolve my sqlite file from eg.
databaseConnection = new SQLConnection();
databaseConnection.addEventListener(SQLEvent.OPEN, onOpen);
databaseConnection.addEventListener(SQLErrorEvent.ERROR, onError);
databaseConnection.openAsync(File.applicationDirectory.resolvePath('mydb.sqlite'));
The key bit here is the File.applicationDirectory.resolvePath('mydb.sqlite') line, in this instance AIR will look for a file called mydb.sqlite in the directory that the application is installed into - in your development environment this would be the same as the bin-debug folder (or whatever folder you are compiling to).
Hope that helps, if not if you can post the code you are using , and what error you are getting I will try and help you further.
The most likely reason is that your DB file resides in the application directory, which is read only.
From Flex 3.5 Language Reference:
File.applicationDirectory—the read-only directory where the application is installed (along with any installed assets)
If this is the case, a possible but not only easy fix would be to just use File.applicationStorageDirectory.
Hope this helps.
N.
I have a db file Resided in Flex Air Bindebug Folder,Here i want to Move/save this db File at another location let say In mydocument/or any Folder, I am not able to do it's programatically..Please help me out here.
Thanks in advance.
Assuming mydbfile.db is the file in your Application Directory:
var fileToCopyFrom:File = File.applicationDirectory.resolvePath("mydbfile.db");
var fileToCopyTo:File = File.documentsDirectory("Copy of mydbfile.db");
fileToCopyFrom.copyTo(fileToCopyTo as FileReference);
This would copy the file to your Documents directory. These are all basic functions weill documented in the AS3 Reference for flash.filesystem.File.
Are your trying to do this via actionscript or in FlashBuilder/Eclipse?
If your trying to move around in The IDE then use ANT.
I have a solution contains a web project named "Web", and a dependeny class library project named "Service". I use the ASP.Net MVC2 to build up my solution. As you know, there's a Content folder storing images and css files under the web project. Now I need to get the stream reference of "Content\Images\anon.png" in one class of my "Service" project.
I tried
var result = new FileStream(#"Content\Images\anon.png", FileMode.Open);
and press F5 to debug, but it cannot find the file and throws an exception.
I am using VS2010, please tell me how can I access to this image. Thanks very much.
Can you try
Server.MapPath("~/Content/Images/anon.png")
You can use System.Web.VirtualPathUtility.ToAbsolute("~/Content/Images/anon.png"); or RequestContext.HttpContext.Request.MapPath as well
Visual studio makes it to a temp directory for your web app, not your solution folder/ If you publish your app on a IIS server, the Server.map will be correct.
Because it is searching for the file in Debug\Content\Images\ . Are you sure the images is really there? Make sure that your file is in that path.
how to write a file to File.applicationDirectory in flex. i am getting security filewrite resource error.
You can't use File.applicationDirectory in pure flex , it is ment to be used only in air applications.
in flex you can use Filereference.save() which opens a dialog box where user can select the folder to save the file in.