What is the best way to include external files in an application?

I am developing a vocabulary-training program (Adobe AIR using Flex Builder 3). Asks you what an equivalent of a czech word is in english and the other way. I am storing the "dictionaries" in external XML files. I would like to include about twenty of them in the installation. So far I just had them in the applicationDirectory, but now, I added an editing feature and I ran across the fact, that I cannot write into the applicationDirectory. So I figured the most intuitive place for the dictionaries would be in the documentsDirectory/name of program. However, how do I tell the AIR installation to make the according folder and include the files?
How do I do this, or what do you think is a better solution? Thanks!

If this post answers your question or helps, please mark it as such.
I'm creating an application that stores data in the "applicationStorageDirectory".      
Mac storage directory is <appData>/<appId>/Local Store/
  where <appData> is user preferences folder, typically /Users/<user>/Library/Preferences
Win: storage directory is <appData>\<appId>\Local Store\
  where <appData> is typically C:\Documents and Settings\<userName>\Application Data
  Note: Vista uses "junctions", which behave like shortcuts but look just like regular folders.
    It is not possible to access them, and any attempt to do so will give you an "Access Denied" error.
    Here is the real folder location:
      C:\Users\<userName>\AppData\Roaming\ContactManager\Local Store\contacts.xml
Linux: <appData>/<appID>/Local Store/    where  <appData>  is  /home/<user>/.appdata
Here is how to code to read from and write to a file there in an AIR app:
var contactsFile:File;
var contactsXML:XML;
var contactsXLC:XMLListCollection;
var stream:FileStream;
contactsFile = File.applicationStorageDirectory;
contactsFile = contactsFile.resolvePath("contacts.xml");
stream = new FileStream();
if (contactsFile.exists) {
    stream.open(contactsFile, FileMode.READ);
    contactsXML = XML(stream.readUTFBytes(stream.bytesAvailable));
    stream.close();
    contactsXLC = new XMLListCollection(contactsXML..contact);
}else{
    var outputString:String = '<?xml version="1.0" encoding="utf-8"?>\n<contacts>\n';
    for each(var xml:XML in  contactsXLC){
      outputString += xml.toXMLString();       
      outputString += "\n";
    outputString += "</contacts>\n";
    outputString = outputString.replace(/\n/g, File.lineEnding);
    stream = new FileStream();
    stream.open(contactsFile, FileMode.WRITE);
    stream.writeUTFBytes(outputString);
    stream.close();

Similar Messages

  • What's the best way to include many files into a website?

    I have a several hundred documents that I would like to load onto my website. I'm trying to find a faster way than hyperlinking them all one by one. Right now they are in pdf format but that can change. I'm hoping for the end result to be one page (possibly with subpages) with the different links for the documents on them. The visitor doesn't necessarily need the ability to download them, just the ability to view them. Is there a faster way to bulk or batch load multiple files into a site? Thanks in advance.

    Getting PDFs to download is fairly easy and the method is described here.....
    http://www.iwebformusicians.com/WebMusic/PDFs.html
    To get multi page docs to display in the browser requires the use of Google Docs viewer, ISSUU or some such thing....
    http://www.iwebformusicians.com/PromoPage/ISSUU.html
    Safari is the only browser I know of that will display PDFs in an iFrame without a plugin.

  • What is the best way to include an xml file in JSP?

    I have a jsp page that I need to include an xml file. The xml file
              uses an xsl to render the file. What is the best way to include the
              xml file and still maintain the structure of the style sheet?
              Thanks
              Jennifer
              

              The best way is using the tag lib. If you cannot, but you can use JAXP, you can
              try
              javax.xml.transform.Transformer.transform(Source xmlSource,
              Result outputTarget)
              throws TransformerException
              You construct the transformer with you xsl, use you xml file or DOM to form xmlSource,
              and use JSPWriter "out" to form outputTarget (StreamResult). But if your JSP page
              generates the xml itself, tag lib is the only way.
              [email protected] (Jennifer) wrote:
              >[email protected] (Jennifer) wrote in message news:<[email protected]>...
              >> I have a jsp page that I need to include an xml file. The xml file
              >> uses an xsl to render the file. What is the best way to include the
              >> xml file and still maintain the structure of the style sheet?
              >>
              >> Thanks
              >>
              >> Jennifer
              >
              >Or is there a way to parse the xml file with the jsp page to display
              >the information. I cannot use the Java Standard Tag Libraries as the
              >version of iplanet we are running does not support the JSTL
              >
              >Thanks
              >
              >Jennifer
              

  • What's the best way to removed unwanted files?

    I have an iMac G4 running OS X 10.4.11 with 1GB of DDR SDRAM. I'm wondering what's the best way to remove unwanted files from the RAM, if it's even possible. There are apps and other files I no longer need. If I can dump the unused files will it help the computer run a little faster? Can I eliminate the unwanted files some how by myself or do I need a program that does it? Thanks

    bad dad wrote:
    I have an iMac G4 running OS X 10.4.11 with 1GB of DDR SDRAM. I'm wondering what's the best way to remove unwanted files from the RAM, if it's even possible. There are apps and other files I no longer need. If I can dump the unused files will it help the computer run a little faster? Can I eliminate the unwanted files some how by myself or do I need a program that does it? Thanks
    Applications are stored perminately on the harddrive [ Macintosh HD ]. When applications are running that is when they appear in a window, they take up RAM. You see your running applications by using activity monitor:
    Macintosh-HD -> Applications -> Utilities -> Activity Monitor
    Application when they are not running, they do not take up RAM.  You will not see any performance improvement when you delete an application from your Harddrive.  [ unless you have filled up your harddrive ]
    Best to have greater than 2gig of free space on your Harddrive.  Many posters to these forums state that you need much more free space: 5 gig to 10 gig or 10 percent of you hd size.
    Most applications do not take up much space on the Harddrive.  I copy my unused application to a folder named additional applications.
    (0)
    Be careful when deleting files. A lot of people have trashed their system when deleting things. Place things in trash. Reboot & run your applications. Empty trash.
    Go after large files that you have created & know what they are.  Do not delete small files that are in a folder you do not know what the folder is for. Anything that is less than a megabyte is a small file these days.
    (1)
    Run
    OmniDiskSweeper
    "The simple, fast way to save disk space"
    OmniDiskSweeper is now free!
    http://www.omnigroup.com/applications/omnidisksweeper/download/
    This will give you a list of files and folders sorted by size. Go after things you know that are big.
    (2)
    This will save you a gig of space.
    Monolingual is a program for removing unnecessary language resources from Mac OS X,in order to reclaim several hundred megabytes of disk space. It requires at least Mac OS X 10.3.9 (Panther) and also works on Mac OS X 10.4 (Tiger). It worked for me on 10.4
    http://monolingual.sourceforge.net/
    A detailed write-up on how to use Monolingual:
    http://www.jklstudios.com/misc/monolingual.html
    (3)
    These pages have some hints on freeing up space:
    http://thexlab.com/faqs/freeingspace.html
    http://www.macmaps.com/diskfull.html
    (4)
    Buy an external firewire harddrive.
    (5)
    Buy a flash card.

  • What is the best way to safeguard my files and pictures before I send off my MacBook Pro to get fixed?

    What is the best way to safeguard my files and pictures before I send off my MacBook Pro to get fixed? I am running Mavericks and use an AirPort Time Machine to back-up all my files.

    Back up all data on the internal drive(s) before you hand over your computer to anyone. You need at least two independent backups to be completely safe. There are ways to back up a computer that isn't fully functional—ask if you need guidance.
    If privacy is a concern, erase the data partition(s) with the option to write zeros* (do this only if you know how to restore to an empty drive.) Don’t erase the recovery partition, if present.
    Keeping your confidential data secure during hardware repair
    Apple also recommends that you deauthorize a device in the iTunes Store before having it serviced.
    *An SSD doesn't need to be zeroed.

  • What is the best way to merge a file content into log file

    What is the best way to merge a file content into log file.
    In worst case, I will read the file line by line as string, then use
    logger.info(lineString)to output to log file.
    However, is there better way to do this?
    The eventual log file will be something like:
    log message 1
    log message 2
    content from file line 1
    content from file line 2
    content from file line 3
    log message 3
    log message 4Thanks

    John618 wrote:
    Thank you and let me explain:
    1. What do you mean by better?
    I would like to see better performance. read line by line and log each line as string can be slow. Did you measure this and determine that it is actually a problem for your application? Or are you guessing?
    Regardless of what you do you are still going to need to read the file.
    >
    2.The only better way I can think of is not having to do it, but I assume you have a very good reason to want to do this.
    Yes, I have to do it beacuse the requirement is to have that file content be part of logging.
    Any idea?How is it supposed to be part of it? For example which of the following is better?
            File AAA - contents
                       First Line
                       Second Line XXX
            Log 1
                    2009-03-27 DEBUG: Random preceding line
                    2009-03-27 DEBUG: First Line
                    2009-03-27 DEBUG: Second Line XXX
                    2009-03-27 DEBUG: Random following line
            Log 2
                    2009-03-27 DEBUG: Random preceding line
                    2009-03-27 DEBUG: ----- File: AAA -------------
                    First Line
                    Second Line XXX
                    2009-03-27 DEBUG: Random following lineBoth of the above have some advantages and disadvantages.
    The first in a mult-threaded app can end up with intermittent log entries in between lines, so having log lines with thread ids becomes important.
    The first can be created by reading one line at a time and posting one at a time.
    The second can be created by reading the entire file as a single string and then posting using a single log statement.

  • What is the best way to find a file on the servers disk without using web.xml?

              What is the best way to find a file on the servers disk without using web.xml?
              I want to find a configuration file not contained within the war file I have
              created. Is there a way to pass information into the ServletContext with out
              rebuilding the ear or war files? Tomcat 4.0 can do this in its server configuration
              files. Does BEA have the equivalent?
              Regards,
              Eric
              

    You can specify the path to the file as a system property
              eg
              java -Dconfig.file.location=./mydirecotry/myfile.txt com.test.MyApp
              "Eric White" <[email protected]> wrote in message
              news:[email protected]..
              >
              > What is the best way to find a file on the servers disk without using
              web.xml?
              > I want to find a configuration file not contained within the war file I
              have
              > created. Is there a way to pass information into the ServletContext with
              out
              > rebuilding the ear or war files? Tomcat 4.0 can do this in its server
              configuration
              > files. Does BEA have the equivalent?
              >
              > Regards,
              > Eric
              

  • What is the best way to name a file?

    What is the best way to name a file? Use "_" so that the characters make one, long name? Why do that?

    Another take on naming files, particularly image files, is like this:
    I use a file remaning application like Name Mangler to back, sequentially rename the photos.  I put them in a folder with a similar name.  Using the format I do, YYYY-MM-DD- Description-001.jpg, they are easy to sort by date by sorting alphanumerically.
    OT

  • What is the best way to keep your files organised

    I would like to know what is the best way to keep your file organise when I am
    Loading program's like numbers and pages from iPhone to MacBook i alway 
    Get double of the same work sheet

    I would like to know what is the best way to keep your file organise when I am
    Loading program's like numbers and pages from iPhone to MacBook i alway 
    Get double of the same work sheet

  • What is the best way to run .exe files on my mac?

    What is the best way to run .exe files on my mac? I need to run some updates for my john deere gps and the downloads i get can only be run on windows.

    There are several options for running Windows software (*.exe files) on a Mac, depending what your program is, how often you use it, and your personal preferences.
    One way that does not require Windows is an open source effort called WINE.  Check out winehq.org.  You may find that that's all you need for your programs.  There is also a commercial effort that has grown from WINE, and you will find info about it on the site mentioned.  These DO NOT require that you have and install Windows.
    If you want to run sessions devoted only to Windows software, and want programs to run as fast as they do on a PC, the Apple's Bootcamp program is useful.  With it you dedicate a partition on your hard disk to windows, and on startup choose to either boot into OS X or Windows.  Each runs without any connection to the other.  This requires you have a copy of the Windows software as well as the applications you want to run. 
    If you want to be able to easily exchange data between your Windows and Mac programs, and skip back and forth between the two, there are several emulators available that run on Mac OS X and create a Windows environment where many Windows programs can operate along side Mac programs.  Parallels and VMwear are two comercial packages available for purchase and Virtual Box is an open source effort available for free.  Google will find all three for you.
    My only experience is with Virtual Box.  It is slow and a bit clunky, but it is free and meets my needs for the very few "just got to have" windows programs I sometimes use.
    Google is your friend on this and can provide a lot more, and better, information than I can.
    Best of luck,
    Ray

  • Using the new iPad, what's the best way to watch video files (away from home) which are stored on a NAS (WD My Book Live)? Any help would be appreciated!

    Using the new iPad, what’s the best way to watch video files (away from home) which are stored on a NAS (WD My Book Live)?  Any help would be appreciated!

    Before you go, move the files to I tunes and sync them down.  There is no viable way to stream from your nas drive to the pad.

  • What is the best way to add external C++ code to LabView 6.1?

    I have various C++ class-based DLL's written with Visual Studio 6.0 and wish
    to create instances of these C++ classes and call their methods in LabView
    6.1. What is the best way to do this?
    It seems based on the little reading I have done that there are two choices:
    1. Wrap the C++ class as a simple COM control and use LabView's COM based
    VIs to create a COM object and access the methods of various interfaces.
    2. Wrap the C++ class methods as C functions and a "constructor" and
    "destructor" C function to create and destroy an instance of the class. Then
    use LabView's DLL call support.
    Which is best? What direction is LabView going to take that better supports
    the notion of C++ class libraries?
    Thanks,
    Te
    rry

    You could also try using a CIN. This is a tool that LabVIEW provides for interfacing with external code.
    The CINTools libraries of LabVIEW allow you to embed compiled C code into a particular Virtual Instrument (VI) using a CIN.
    In order for LabVIEW to be capable of calling compiled functions of C from a running VI, the code must be loaded and unloaded into memory at the same time as the VI code itself. LabVIEW uses object code in the form of a .lsb file which is generated by the C compiler from the C source code using the ntlvsbm.mak file. This ntlvsbm.mak file is included in the CINtools directory in the LabVIEW folder. You also must create another .mak file which includes parameter definitions for the ntlvsbm.mak file and also includes a call to the LabVIEW .mak file.
    The generic documentation for CINs only explains how to use them to call C compiled code from a LabVIEW VI. It shows several development environments such as Visual C++, but in essence it only allows the user to create .lsb files out of plain C source code ( .c ) through C compilers on those environments.
    The question now is how can I create .lsb files from C++ native source code using a C++ compiler. Furthermore, how can I create a .lsb file from several C++ source code files (.cpp) and make calls to C++ functions from a VI using CINs? The following explains how to do this:
    1) Drop a Code Interface Node (from the Advanced Subpalette of the Functions Palette) into the LabVIEW VI. Make sure to wire the inputs.
    2) Right-click on the CIN and choose "Create.c File...", then in the file dialog box specify a "name.cpp" file name. (very important: use .cpp extension)
    3) Then create a name.mak makefile (text file) and add the following lines :
    name=name_of_cpp_file_without_the_extension
    type=CIN
    cinlibraries=Kernel32.lib
    CINTOOLSDIR=path_to_cintools_directory
    !include <$(CINTOOLSDIR)\ntlvsb.mak>
    4) Go into Visual C++ and File>Open and open the .mak file. You can even Add the name.cpp file to the project to make it easier to edit. Select that name.cpp or open it as a text file in NotePad or and edit the prototypes of the CIN MgErr functions as shown below, adding extern "C" at the beginning of the line. extern "C" CIN MgErr CINRun(float64 *INPUT);3) Select Build.exe to create the "name.lsb" file. To import the .lsb into LabVIEW, right-click on the CIN and choose "Load Code Resource...". Then, choose the name.lsb file and it is ready to run!
    If you want to use several C++ source code files with .cpp extensions, then compile them in Visual C++ and link them to name.cpp and create a .lsb by modifying the name.mak as follows:
    name=name_of_cpp_file_without_the_extension
    otherobj=other_cpp_files_BUT_USING_.obj_extension
    type=CIN
    cinlibraries=Kernel32.lib
    CINTOOLSDIR=path_to_cintools_directory
    !include <$(CINTOOLSDIR)\ntlvsbm.mak>
    It's worth a try? I have also heard of using clusters to represent classes, so you could check that out.
    J.R. Allen

  • What is the Best way to Move FCPX files to External HD?

    Im running low on space on the HD,  What is the best way to move events, videos, etc.. to an external HD from FCP X and still have FCPX locate and use them?

    Thanks Tom,
    In the finder in Movies I have motion templates, final cut events, final cut projects.  Is that what you mean by project library?
    The FCPX project library doesnt really have anything in it.
    Thanks!

  • What is the best way to make my file in FCPX Compatible for a DVD.

    I am working with a file that is about 53 minutes in length.  The video is broken up into 14 3to5 minute videos.  During my project, as I completed each video, I saved a master file and shared as APPLE PRO RES so that I wouldnt lose anything as this is my first time working with FCPX.  This made a hi-def quicktime file of each video (came out great). Now I need to put the entire project together.  My individual master files are about 4g a piece and I would imagine putting them together, will be way too large to make a dvd with.
    My question is what is the best way to put it all together and export/share? I have all of the original projects still in FCPX, do i copy and paste them into one big file? Then share, and If I share what format should i share with?  I need to take the file, throw it on a external HD and put on my laptop to create the DVD in IDVD. Needs to be decent quality for the DVD.  I have read that I can create a DVD right from FCPX, but that would be impossible as I am working on a new imac with no burner!
    ANY HELP WOULD BE GREATLY APPRECIATED!

    jpqb48 wrote:
    My question is what is the best way to put it all together and export/share? I have all of the original projects still in FCPX, do i copy and paste them into one big file? Then share, and If I share what format should i share with?
    All sounds good.
    Create a new project and paste your 14 videos (projects) sequentially into it, Perhaps insert a gap clip and put in chapter markers if you want. Share>DVD. Should create a high quality disk.
    Good luck.
    Russ

  • What is the best way to handle .mod files in premiere pro cs4?

    I recently got a JVC Everio GZ-MG130u and as I'm sure many of you are aware, it saves footage in the .mod format.
    I have googled this and found quite a few different solutions, but I'm just wondering if anything has changed since some of these solutions were posted, or in other words, what is the best way at this current point in time to handle .mod files in premiere pro cs4?
    As far as I know, the best thing to do is convert the .mod to .avi and then import it into premiere so it can be edited.. Is there a better way to do it than this? Also, by doing it this way, will I have separate audio and video tracks?
    Thanks.

    I have just done a bit of reading, here. All of the quotes that follow are from users who have posted in that thread.
    It seems that there isn't one solid answer on this subject. The thread that I linked to was started 2 years ago, and replied to just 4 ago, so it's relatively current.
    I noticed a couple different interesting statements:
    posted by mmontgomery:
    In the case of .MOD, you are actually getting a MPEG-2 file. The way
    video files work is that there is a codec (COmpressor/DECompressor)
    algorithm and a file wrapper (or extension). A JVC .MOD file is a
    MPEG-2 encoded file, with a .MOD extension.
    You're faced with two
    challenges, first the .MOD file type is only recognized and support by a
    few applications. I think we covered some of those already. The
    interesting thing about wrappers and extensions is that they can be
    dealt with in a variety of ways. Sometimes all you need to do to convert
    the video file to a compatible video file is to change the extension.
    In the case of .MOD files that's not enough. The .MOD wrapper apparently
    does a few more things than just bare a unique extension name. It
    requires a slightly more complicated method to convert that file. That
    is why there is supplied software and that certain third party
    applications have .MOD support.
    (posted 2 years ago)
    This seems to indicate that Ann's solution of simply re-naming the extension is not good enough, unless I am mis-interpreting what she meant.
    However, another user said:
    posted by futball8:
    I edit with Adobe Premiere Pro CS3. All I have to do is simply rename
    the .MOD files as .MPG and then import into PP CS3. It takes a small
    amount of time to conform the audio, but no file conversion is
    necessary. It's a pretty slick workflow and I've never encountered any
    problems editing them this way.
    (posted 5 months ago)
    One can only assume that simply re-naming the extension from .mod to .mpg works in some circumstances, and doesn't work in others. I assume it depends largely on the editing software being used. Perhaps there are still issues that futball8 was simply unaware of or never encountered.
    That said, there seems to be a couple of different real solutions to this problem that I have found:
    1. Simply use an editing program that supports .mod file format. While pe7 and pe8 supposedly support the .mod format, the following should be noted:
    posted by macksgarage:
    While Elements 'supports' these files, it is markedly unstable and  frequently crashes while using the files, though the application is otherwise reliable.  The solution I have arrived at is to repair the  container using ffmpeg. (see #3)
    (posted 5 months ago)
    2. Use a file conversion utility of your choice that will covert .mod to .avi, or another desired format. Import the resulting .avi file into premiere pro cs4.
    3. Use FFmpeg. This seems to be the best solution as it does not convert any audio or video:
    posted by macksgarae:
    If you are not familiar with ffmpeg, it may be a bit of a bear to
    learn, but it's not only useful for this, but functions as a video swiss
    army knife useful for splicing, muxing/demuxing, and rendering just
    about any format into just about any other format.
    ffmpeg is an open source project from the linux world, but it has
    been ported and is supported on windows.  Fetch it here and place it somewhere handy
    on your system.
    To rewrite the container into a nice, standards compliant .mpg file
    that doesn't make applications die, WITHOUT rerendering video or audio
    itself, I use this command.
    ffmpeg -i INFILE.MOD  -acodec copy - vcodec copy OUTFILE.mpg
    This not only renames the file, but actually rebuilds the container
    around unmodified video and audio data, yielding a file which works much
    more stably with Adobe applications, and presumably others as well, as
    ffmpeg's open source development goals result in very standards
    compliant files.
    (posted 5 months ago)
    Now, this seems to properly address the issues that can arise from simply renaming .mod to .mpg, as suggested by Ann. So from this point, I assume you can simply import the .mpg into Premiere Pro cs4 (or any other .mpg compliant program) and edit without issue, but it seems like I remember hearing something about Premiere not liking mpegs or something like that, so in that case, maybe it'd be better to skip this and go with option #2. But, it's been awhile since I've touched any NLE, much less premiere pro cs4, so I could be completely wrong and it may have no problems handling mpegs.
    All of the things that I've quoted here came from the same thread, so I don't know how accurate any of this is, but the people that have posted these things seem fairly knowledgeable. If someone reads all of this and can confirm or deny any of it, it would be much appreciated.
    Option 1 is not really an option for me, because I am sticking with premiere pro cs4 -- I'm not going to get another editor just because it has .mod support. That leaves me with options 2 and 3: Convert to avi, or change the file wrapper/extension properly with FFmpeg and then simply import the resulting .mpg file... Which is better? Or is there yet another solution that I am unaware of that would be even better?

Maybe you are looking for

  • Apple TV failing to reconnect - why it happens

    As I reported a few days ago (before the thread was locked...) my AppleTV would lose its connection with my server PC every time the PC was shut down and restarted, and would need to be deleted from within iTunes and reestablished every time. In case

  • How to print Vertical barcode in SAP script

    I want to print barcode related items in SAP script . can you plz tell me any one 1.How to print vertical barcode in SAP script ? 2.How to print vertical text in SAP script ?

  • How do I tie icon files to properties of bookmarks?

    When I was using the IE browser, I created icons (****.ico) for my files and bookmarks through properties. When I migrated to Firefox browser, the bookmarks and files were restored, but without the .ico properties. I went to Firefox tools/properties

  • The credit card you entered is not supported in this dimension. Any words on this problem?

    It seems credit cards of all kinds (at least Mastercard and Visa) are being rejected by the iTunes Store today, which remembers me that it has been strange lately asking for data more than necessary on my iPad and computer. I can not buy now as many

  • JTextArea - need event rised on text changed.

    I am making an application which contains a JTextArea. when user writes some data on in, some event must be invoked changing the text of the same JtextArea. Problem is, when i change the text, Java automatically adds to JtextArea typed character, wha