flex air include a directory with the installer - apache-flex

I am creating an AIR application using Flex. In it I need 2 directories downloads & uploads. These directories will have downloaded files & uploaded files.
But the problem is I am not able to create these 2 directories programmatically & also I am not able to include the 2 directories with the installer in the application directory.
Is there any way to create or include directories in the application directory.
Thanks

Create an empty folder inside your Flex project. Right click on your project and go to Properties->Compiler (not exact name but something like that). Make sure it has "Copy nonembedded assets to output directory" (check it if it doesn't). Click Ok.
Export a release build of your AIR app. Do NOT click Finish after the "signing" step. Follow each step until you get to the "assets" screen. It will show you a list of every file and folder in your output (bin-debug, by default) directory.
Check the files you want, uncheck the one's you don't, and click OK. Done. You have your AIR file packaged with whatever file and folder you want.

[...] But I need to create the directories in application directory. I am using: var dir = File.applicationDirectory.resolvePath("upload directory");dir.createDirectory(); And I am getting: at runtime::SecurityManager$/checkPrivilegeForCaller()
This is a know issue. AIR wouldn't allow you to write to the application directory. Instead try writing
either to the File.applicationStorageDirectory (application's scratchpad),
or to the File.documentsDirectory (stuff user might want to lookup)
Related resources:
Adobe AIR team blogpost

Use This Dear :)
var dir:File = File.applicationDirectory.resolvePath("NewFolder");
dir =new File(dir.nativePath.toString());
dir.createDirectory();
Regards
Ali Naqvi

have you tried something like the following
var dir = File.userDirectory.resolvePath("upload directory");
dir.createDirectory();
This will create the directory 'upload directory' if it does not already exist (inside the users home directory).

To add to johncblandii's anwser:
I've found that for the above to work, you also need to include the folder in the project's build path. I also had to refresh the project's file listing before flash builder recognized the folder and added it to the include options.

I just want to add another thing to johncblandii's comment: Create an empty.txt file and write something there. Because it looks like empty folders are nod allowed to be included in your packed application

Related

How to change the default Open File... (folder) in Netbeans 8.2?

How can I change the default Open File... directory in Netbeans 8.2 for Java SE\ME\EE?
I've edited my projectui.properties file line projectsFolder=DIRECTORY but that only works for projects. I am trying to open individual files without opening the entire project.
File was found (Windows) under "C:\Users\MYNAME\AppData\Roaming\NetBeans\8.2\config\Preferences\org\netbeans\modules"
Unlike setting the default project directory in NetBeans, you can't modify the default Open File... directory because there is no such "default directory" to change.
NetBeans behavior when you select Open File... from the File menu (on Windows 10 at least) is as follows:
[1] On the first occasion within a NetBeans session the Documents icon will be pre-selected in the Open dialog window, and your Documents directory will be opened. That's just the way NetBeans works, and cannot be modified. Although you can change the Documents folder that will be opened, you probably shouldn't. See below for details**.
[2] Within the Open dialog you can obviously navigate to any alternative folder to open a file. Thereafter, within that NetBeans session only, that alternative folder will be opened by default on the subsequent File -> Open File... selections, until an alternative directory is selected.
~~~~~
** To change the Documents folder in Windows (which will also change the folder that NetBeans opens on the initial use of File -> Open File..):
In Windows File Explorer select Desktop -> This PC -> Documents and right-click.
Select Properties from the drop down menu, and then select the Location tab in the Document Properties window.
Enter the name of the new folder to be used as the Documents folder and click OK.
Restart NetBeans, select File-> Open File... and the folder NetBeans opens will now be the one you specified in the previous step.
That may appear to have the desired affect, but other Windows applications also use the Documents folder, and may depend on files in that folder, so it shouldn't really be changed without good reason. If you really need to open files in NetBeans that are not within any project the cleanest approach would be to place such files in the Documents folder if possible.
One solution would be to move the NetBeansProjects in the Documents folder mentioned above to the desired place and to place a permanent symlink to the desired folder. Instructions for latter referenced here https://superuser.com/questions/1020821/how-to-create-a-symbolic-link-on-windows-10
Watch out if the secondary location could be temporary (like a network drive) that it's always in place before you launch Netbeans.

Debugging WordPress with PhpStorm and a local deploy setup

I like to keep my project files clean.
E.g. I keep all the files I manipulate in my project folder, and deploy them on to my local developer server on save.
e.g. if I write a theme for WordPress I create:
wp-content
wp-content/themes/
wp-content/themes/mytheme
I certainly don't keep all the files of the whole WordPress installation in my project.
I include those over the include path, then it shows as external libraries
those include all files of WordPress including mine.
Now here comes trouble
When I now press F3 on one of my functions I get "Choose declaration"
well I don't want code on my local deployment never! I always want to code in my project source files, that is, not in "external libraries"
so basically
when I add the include path, I want to have the ability to say
"excluded sub-directory of that include path"
so I can exclude my deployed files from the library. Do you understand what I mean?
is that possible?
"well just remove the include path"
no! without include path I cannot debug. Without include path I don't get auto-complete
I figured it out
the trick was in the end to not use "include path" but the project structure editor and add a different content root folder.
FIle - project structure
or
CTRL + ALT + SHIT + S
looks like this:
click on your module, click on add content root folder, click on the target deploy folder of your deployment scripts, and then exclude the stuff you don't like
it will create a new folder in the project explorer but i don't care about that really.
Remove it from the include that i mentioned in my post earlier, i mean from settings - php - external libraries. YOu don't need that any longer
hope it helps

Server.MapPath does not find the path on Azure

I have deployed my project to Azure. In my project I have "App_Data\Images" folder.
Now I'm trying to do the following:
String filename = GLOBAL_IMAGES_VALS.GET_FILE_PREFIX(imageType) + "-" + User.Identity.GetUserId<int>().ToString() + Path.GetExtension(image.FileName);
String origPath = Server.MapPath("~\\App_Data")+"\\Images\\" + filename;
But then upon trying:
image.SaveAs(origPath);
I get this error message:
Could not find a part of the path
'D:\home\site\wwwroot\App_Data\Images\logo-10003065.jpg'.
How can I save my file to "App_Data\Images\"?
The actual problem was that the sub-folder 'Images' did not exist. I can't remember why the publish process did not create this sub-folder, however I added it manually and then everything worked fine.
EDIT:
As others wrote here (#Spectarion). I'll put here the important remark that explain why the folder was not created:
Just for the future readers, folder won't be created if it's empty.
Folder is empty even if there are files that are not included in
project.
Just put some 'fake.txt' file into any folder you want to make sure that it will be created, and of course don't forget to add it to the project. Good luck.
Since you don't have any file in the particular folder, while publishing Web deploy ignores the empty folder.
Quick fix: Add any file to the folder before publishing will fix this issue.
if (!Directory.Exists(Server.MapPath("~/Images")))
{
Directory.CreateDirectory(Server.MapPath("~/Images"));
}
The directory might be missing in the folder. Create the directory and use it in file path
Maybe this :
System.Web.Hosting.HostingEnvironment.MapPath("~\\App_Data")+"\\Images\\" + filename )
Maybe the images folder doesn't exist and you need to create it first? Although I wouldn't recommend saving images in your app like this if it is designed for people uploading images. I would save them in Azure storage via blobs or the new Azure File storage. I would keep your app deployment files clean just related to your app and save any user generated content outside of it.
BTW, If you are using Azure Web Apps you can use the environment variable of "HOME" to always get the correct path (which should be D:\home)
string path = Environment.GetEnvironmentVariable("HOME") +
"\\site\\wwwroot\\App_Data\\images"
I assume your AppData folder is just under the wwwroot folder, which is usually the case.
Try this:
HttpContext.Current.Server.MapPath(Path.Combine("~/AppData/Images/", filename));
I just had this problem on VS15. I first followed the advice in this question in order to generate the error you've got. I'm guessing this follows in part dsb's answer, but dsb hasnt given any description of the actual process of fixing this.
I then went to https://<mywebsite>.scm.azurewebsites.net/DebugConsole to look through the directory and found that App_Data had not been published
Which was why the error was throwing. So, I then solved this by simply going to the solution explorer, right clicking App_Dataand selecting to "Publish App_Data".
However, my website was a short-term academic effort for a project - I think there is probably a lot to be said for considering Matt Watsons answer above about whether or not allowing users to upload to the deployment area is a good idea

Reading in existing file in Flex 4.6

Alright, I'm really new to flex. I have a data file on my computer that I need my flex mobile app to read from. Is it possible to put this file in a certain location on my computer so that the app will see it when I'm testing(ex-can i put it in a folder that is linked to the applicationstoragedirectory directory)? Thanks
You can just drop it in the source folder, it will automatically be copied into the bin-debug folder (there are a few choice exceptions that you can find in the window->preferences->Flash Builder->File Exclusions) Everything that is copied into the bin-debug would also be packaged into an air or airi file and ultimately deployed next to the bytecode/executable just like it is in the bin-debug in the builder.
You can also make another folder, say "resources" then in the project properties in the flex build path go to source path tab and click add folder button and type "resources". Then it will treat that and the src folder the same.

How to create a solution file using vs 2008

I have all the files for the deployment listed below :
-BIN
-CSS
-IMAGES
default.aspx
PrecompiledApp.xml
Web.xml
The above files can be copy pasted in the webapps folder and default.aspx could be run from the browser.
i want to create a solution sln file from this. How to create a solution file?
A solution is merely a container of projects. If you create a project containing these files, the solution file will be created automatically in the same directory (unless you specify otherwise).
File -> New Project
Expand Other Project Types, Select
Visual Studio Solutions
Under Templates, ensure you have
selected Blank Solution
Enter a name and a location for the
solution and click OK
File -> Add -> Existing Web Site
Select the folder that contains your
website and click Open
It looks as though you are creating a web site. I've never been able to create a solution with just a website in it (a web application is a different beast however). However, I have found a workaround, although it's a little cludgy. Create a new class library project (any project type will do really). This will create the project file. Then File -> Add -> Exisiting Web Site. Point to your existing web site and add it. This will create the solution file as you now have two items. You can now delete the first project that you created. This will leave you with a solution file with one web site in it.

Resources