Save the .txt file - works in a desktop not on device application

Hello everyone. Im trying to save the text in a TextArea in a .txt file and have been able to do in a desktop Air application but cannot make it work for the BP. I made sure to make access_shared, the problem is in my code.

private function saveFile():void
            {
                if (currentFile) {
                    if (stream != null)
                    {
                        stream.close();
                    }
                    stream = new FileStream();
                    stream.openAsync(currentFile, FileMode.WRITE);
                    stream.addEventListener(IOErrorEvent.IO_ERROR, writeIOErrorHandler);
                    var str:String = mainTextField.text;
                    str = str.replace(/\r/g, "\n");
                    str = str.replace(/\n/g, File.lineEnding);
                    stream.writeUTFBytes(str);

                    stream.close();
                    dataChanged = false;
                }
                else
                {
                    saveAs();
                }
            }
private function saveAs():void
            {
                var fileChooser:File;
                if (currentFile)
                {
                    fileChooser = currentFile;
                }
                else
                {
                    fileChooser = defaultDirectory;
                }
                fileChooser.browseForSave("Save As");
                fileChooser.addEventListener(Event.SELECT, saveAsFileSelected);
            }

            private function saveAsFileSelected(event:Event):void
            {
                currentFile = event.target as File;
                saveFile();
                dataChanged = false;
                currentFile.removeEventListener(Event.SELECT, saveAsFileSelected);
            }

I got the Save pop-up dialog box but nothing happens.

Oops. turns out it was as simple as

private function saveFile():void
            {
                var fileRef:FileReference = new FileReference();
                fileRef.save(mainTextField.text, "myfile.txt");
            }

Tags: BlackBerry Developers

Similar Questions

  • I have a pdf file that contains the text if I copy all the text and paste it into Notepad and save the .txt file is it changes the ascii value of the text?

    I have a pdf file that contains the text if I copy all the text and paste it into Notepad and save the .txt file is it changes the ascii value of the text?

    If the encoding is ASCII? Laughing out loud

    Be well...

  • How to save the .txt file without opening a dialog box.

    Hello..

    How to save the .txt file without opening a dialog box.

    It is impossible to Flash running in the browser.

  • How do I sort the rows of the table that belongs to the same name and save the .txt file?

    Hello

    I am facing a problem, I read the .txt file that has several lines and columns.

    Third column represents the name of the group, as Group 1, group 2 and group 3. attached .txt file in the annex.

    I wanted to generate the wise group .txt file, as all the raws that 3rd element name group 1 must be in a .txt file and all lines that has 3 name group 2 element must be a .txt file.

    I hope that I explained my problem.

    pelase guide me how can I have the solution for this problem.

    Thank you much in advance.

    Kind regards

    Ankit.

    I have provided a simple example that works.  Feel free to use any method best suited to your needs as there are already several good ideas on this thread

  • Save the text file on the desktop

    Hello world

    See my code below. It saves the text file in the root folder. But I want to save my file of text of the report on the desktop in a folder called report.

    Secondly, when I run this script twice, he adds comments twice in the text of the report file and does not replace the text file report.

    Can someone please correct this JS script.

    function write (text) {}

    var myDocName = app.activeDocument.name;

    var myFilePath1 = + ' / ' + 'Report' + ".txt";

    var monFichierTexte = new queue (myFilePath1);

    If (myTextFile.exists)

    {

    myTextFile.open ("e");

    myTextFile.seek (0, 2);

    }

    else {}

    myTextFile.open ("w");

    }

    myTextFile.write (text + "\r");

    flag = true;

    myTextFile.close ();

    myTextFile.execute ();

    If (flag == false) {}

    Alert ("no error")

    }

    }

    Thank you

    You have contradicting wishes.

    Compare this sentence

    designmon79 wrote:

    I need a code JS that replace my office report text file (if the output) and write the cool comment text in the file.

    with this

    It replaces the report file, but also delete text in the file.

    It seems obvious that if you replace the previous file, the old content will be deleted.

  • to access the txt file in vi executable

    Hello

    I built a UI for a project im working on. The data entered by the user on the interface are stored in a text file to the closure of the programme. Currently, it works fine but when I create an executable of my code, data are not written in the txt file to the fence. Is it possible to build these types of screws, special

    Code to write to the file is located in a sub VI and I use the function "Write to the spreadsheet file", I go to 'C:\Documents and Settings\asha264\Desktop\Single Line\Single (9.0)\Data.txt Line' reference.

    Thanking you,

    Adnan Sharief

    Make sure that your means of signalling of other vi until the output is not a condition of competition inadvertently. Don't forget that LabVIEW is data flow language, to make sure that certain events occur in a certain order, that there is a dependecy signal to force the order of execution. I got bit by that recently, when we used a functional overall to report all the different programmatic loops in the vi while it was time to stop. There was at least one place where, under certain conditions, the Terminal stop loop became the front signal had executed the "stuff" in the loop. Put an in/out error on the FG, then put in the error line after the functions (in fact file writing) guaranteed that the Scriptures of file occur before that the 'exit' condition was assessed.

  • Problem with registration of data in the txt file

    Hello

    I have 2009 Labview, Labview real-time 2009 and cRIO 3.3.0. I also NEITHER cRIO-9024 more cRIO-9112 chassis and modules.

    I would like to save the data measured modules in the txt files, but I want to do in a period of time to time desire. For example, I want to save data of measurements of 60 seconds and repeat every one hour. I of the project (in the file attachment vi) and normally it works fine but I noticed that the recording of the data is not correct. I mean it seams to save what was in the memory before. That's the problem with Windows XP I have check with another computer with Vista and it seems to be ok. It seems that on XP the buffer (refnum?)  is not clear and it retains the previous values.

    Can someone explain to me why it happened and how I can obey Windows XP? Or maybe there are techniques to clear the memory buffer/refnum for rescue?

    Thanks for any help.

    Kind regards

    Kamil


  • Re: How to save the video file to a DVD-R for Equium A200

    I have the Equium A200. Someone can tell me how to save the video file to a DVD-R on my computer in order to use it later, or use it in windows movie maker and must not simply copy on another DVD-R right?

    My cursor also has disappered in the suite of windows media, that makes life quite difficult.

    Any ideas?

    Thank you.

    You mean, you want to copy the original DVD movie to HARD drive?
    Well, you can copy the contents of the entire DVD to the HARD drive. It means that you have to copy a lot of data.
    I would recommend shrinking the DVD movies using a tool called DVD shrink.
    It would decrease the data and would also copy the content to the HARD drive.

    But if you want to use these files later in windows movie maker, so you must convert these using a 3rd party tool.
    Google a bit and you should find many free applications that would help you to do this work.

    Good bye

  • How to make a temporary directory on my HARD drive to save the downloaded file?

    I need to download the updated printer drivers and the first thing I need to do is to create a temporary directory on my hard drive to save the downloaded files.  My operating system is Windows 7, the 64-bit version.  My printer is a brother model MFC - 240 c.  (That copy, fax, scan and has Photo Capture).

    I had a stroke and lost my short-term memory and can not remember what whether computers or at least, not a lot.  If you know how to do this, be very specific with your answer as I print it and use it as a guide I'll follow to the letter.  I'm sure that it's the easiest thing, but I just can't remember how to do it.

    Thanks for your help - it is much appreciated.

    Waylin

    I need to download the updated printer drivers and the first thing I need to do is to create a temporary directory on my hard drive to save the downloaded files.  My operating system is Windows 7, the 64-bit version.  My printer is a brother model MFC - 240 c.  (That copy, fax, scan and has Photo Capture).

    I had a stroke and lost my short-term memory and can not remember what whether computers or at least, not a lot.  If you know how to do this, be very specific with your answer as I print it and use it as a guide I'll follow to the letter.  I'm sure that it's the easiest thing, but I just can't remember how to do it.

    Thanks for your help - it is much appreciated.

    Waylin

    You shouldn't really need to create a temporary directory - especially for the Brother printer drivers.  You can download it at any place that you can easily find (like the office).  Then double-click it to run it (run) on it and let it install.
     
    I realize has their instructions (probably the ones found here<-- that="" is="" a="" link)="" say="" to="" download="" the="" file="" to="" a="" temporary="" directory="" -="" but="" i="" just="" downloaded="" the="" file="" you="" need="" (mfc-240c-inst-win7-a2.exe)="" and="" double-clicked="" on="" it="" and="" it="" doesn't="" have="" to="" be="" anywhere="" special. ="" it="" will="" 'extract'="" to="" the="" native="" temporary="" directories="" as="" needed="" (nothing="" to="" be="" concerned="" with)="" and="" then="" ask="" you="" to="" choose="" a="">
     

    Which I suppose you want to English (as shown), and then you click OK.

    He then expand some additional files and then ask you to accept a license agreement (I suggest "Yes" If you want to go further):

    In your case... choose 'Standard' and click Next and continue in this way until it is installed.  Then (once Setup is complete and closed) you can restart the computer (first and foremost) and then delete the original file you downloaded (MFC-240 c-inst-win7 - A2.EXE) on your desktop (or downloads, etc.)

    You should get through it.

  • Suddenly, the 64-bit Windows 7 Media Player doesn't have a location to save the ripped files. How can I fix it?

    Suddenly, the 64-bit Windows 7 Media Player doesn't have a location to save the ripped files. It is impossible to rip CDs. How can I fix it?

    You can order these links on ripping...

    You can try this procedure to restore your windows media player.

    (1) Perform SFC first. Follow the link on how to make SFC (http://support.microsoft.com/kb/929833)

    (2) turning on Windows Media Player again.

    a. go to start and in the search type 'Turn Windows has or not'.

    b. click on the "Turn Windows features on or off".

    c. check the "media features.

    d. restart the computer.

    You can also try restore (http://windows.microsoft.com/en-us/windows7/products/features/system-restore) your computer to the final point where windows media player worked.

    Or you can use the previous versions of windows media player that comes from restore points or windows backup.

    Or you can try to run 'Fixit '.

    http://support.Microsoft.com/mats/windows_media_player_diagnostic/

  • How to save the. File of ATN in Photoshop CS5 screen area

    How to save the. File of ATN in Photoshop CS5 screen area

    Hello

    Greetings!

    Open Photoshop.

    Open the Actions panel and select the action that you want to save to the desktop.

    Click the option panel (arrow pointing down with 4 rectangles)

    Choose Save Actions from the menu and choose the place like office and save.it

    Concerning

    Jitendra

  • Is there a way for EA to automatically save the audio files in the project and publish directories &amp; json?

    Is there a way for EA to automatically save the audio files in the project and publish directories & json? Thank you

    Bob

    good edge would not copy all the external files that you have added to your project in the publication of record, you should only do copy paste your files and folders created by your self after publication!

    and I can not undrestand "Unlike you, I'm not that qualified and often make mistakes that make some of my totally useless code retries." You can save your project every time with the new name to have your previews works!

    and on the withdrawal of your symbols that uses the name of the class, you're hurting, you should do it this way

    SYM $(".) Preview"). Remove();

    and that's why you can not make it work

    If tehre is any question feel free to ask me questions

    Zaxist

  • Force firefox to open, not save the .url files.

    Hello!

    I need a way to Force Firefox to open, not to save the .url files. These files are generated by an application. The application is listed in the list of software and has the setting to open. But when the. URL link is clicked it will ask only to save. I need to open the file. not to save it.

    Thanks in advance.

    A .url file is a type of special file created by Microsoft.
    Firefox is a cross-platform application and can't stand all the platform-specific files as does a browser that is designed for this platform.

    Try to ask for advice on forum of stack overflow's website to see if they know of an alternative.

  • read the specific number of the txt file

    Hello

    Anyone know how to read specific numbers to a txt file.

    If the operator choose tab1. The values displayed will be the first list of numbers. Otherwise the values shown on the table are the second list

    Thanks in advance for your help

    Please find enclosed my VI and the txt file

    My best regards

    Nadia

    The format of your example tab.txt file in do you need?

    If not, I do not consider using a format such as LabVIEW Config File VI or a common standard such as XML.

    If you don't need the exact format in the example, then you will need to write your own parser for him.

  • The attached VI works when I run it initially to create the XML file, but by pressing once the XML file is created, it is not up-to-date. What I am doing wrong?

    The attached VI works when I run it initially to create the XML file, but when I change the data and run once the XML file is created, it is not updated with new data. What I am doing wrong?

    Thank you.

    It sounds like the logic that has been written in VI

    Internal decision of true / false:

    (file exists: false) write in the file XML, unflatten for display

    (file exists: true) read the XML file, unflatten for display

    At no time when the file exists (true case) is the XML file updated...

Maybe you are looking for