How to check if a file is already open

My question is about subject local filesystem "file." I write a function that reads the contents of a text file. The function a "File" object is passed as an argument and then reads the contents before another logic.

Before you can read a "File" object it must be open. The Adobe JavaScript documentation has the following warning around opening files:

NOTE: Be careful about opening a file more than once. The operating system allows generally of do, but if you start to write in the file by using two different objects of the file, you can destroy your data.

So my question is... How can I tell if a file object is already open? It doesn't seem to be a property or a method that simply tells me this.

Hello

Suggest to use the file.tell () method ==> which returns "-1" If the current position cannot be found.

If the file is open, it returns the number > = 0.

Jarek

Tags: InDesign

Similar Questions

  • How to check the HP files as not being is not a virus?

    I have a Compaq Presario SR2027X desktop computer comes with XP Media Center 2005. It has been updated to SP3.

    Recently, I ran free TDSSKiller from Kaspersky Lab to check my PC for the DNSChanger Malware. After executing TDSSKiller, he registered 6 files to be suspicious. Both files from HP. The files and their paths are:

    (1) LSSRVC.exe.  Path: C:\Program Files\Fichiers Files\LightScribe\LSSrvc.exe

    (2) HPZipm12.exe. Path: C:\WINDOWS\System32\HPZipm12.exe

    How to check that these files have not been modified by a virus?

    Thanks, Terry

    It may be simply a false opinion. Try another scanner as MS:

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

  • File is already open on another copy of the Muse + hours missing

    I open a file, I had worked on that in muse a few days ago and I get a strange message on "file is already open on another copy of the Muse. After this error in levant and learning that I can copy the file to a new location, I was able to open the file. He then told me that there have been changes on the site online (which was false). It turns out that the file Muse lost hours of my work, but saw the changes I made on the live site and thought they were updated in the browser. Now, I'm sure I had saved the work at regular intervals, I'm pedantic enough stuff to 99%, I remember having a failure of the system at the time, but I was under the work of backup automatically Muse impression anyway? Surely a system crash should not corrupt a file like this to the point that he didn't even remember saves work? Any advice greatly appreciated.

    Please send us the .muse file and the file 'MuseLog.txt' to the 'Documents' folder so that we can investigate. Also check your hard drive to confirm that a newer version of the file has not been saved in a different folder. Thank you.

    Send files to [email protected] along with a link to this topic for the context. If files are larger than 20 MB, you will need to use a service like Dropbox, Adobe send, WeTransfer, etc..

  • Hello. I explained the following error in InDesign. When you open a file that is stored on a server, I get an error message because the file is already open, or don't have sufficient permissions. If I copy to the desktop and open it, I have no p

    Hello. I explained the following error in InDesign. When you open a file that is stored on a server, I get an error message because the file is already open, or don't have sufficient permissions. If I copy to the desktop and open it, I have no problem. Can someone help me? Thank you.

    Is there a file .idlk remaining on the server which is not removed properly?

  • File is already open in another copy of Muse.

    I came to work this morning and turned on my computer.  Since there a network disconnect my Muse file that I had opened and functional on crashed immediately when I hit.  (Sorry, I don't have no record or intercept the error).

    Trying to re - open the file from the network, I get the following error message, and the file does not open always.

    "File is already open on another copy of the Muse."

    There is no other soul on this planet with that file open right now.  Not a single one.

    Please help me to recover this file... There is a bit of work so far that I don't want to lose.  This is the first time I've ever had this happen.  We have worked with Muse CC 2014 of a network since its output file location.

    Nevermind, copy the "corrupt" file and its assets of network on my hard drive, I could open the file successfully without error.  I recorded a new copy and added to the network.  Moving along now.

  • How to check if a file exists?

    Hi guys.

    I am running javascript in Acrobat .pdf file created in LiveCycle Designer.

    I need to check in silence if an external file outside the open document (C:\something\something\something.pdf) exists or not.

    I understand that I'm only able to do this as a function of confidence within a script to the folder level javascript.  I am familiar with those.   The problem is, I don't know what function I should use and will have a difficult time in the research on it.

    Try to use: doc.exists?

    Try to open the document with a function and catch the error if the file does not exist?

    I'm not so sure that if I just spend my path as a string, say "/ C/Something/something/something.pdf" or if I should first deal with the file as an object like:

    var myFile = new File("/C/Something/something/something.pdf") (which was not in Acrobat... don't try to run it as a function of confidence)

    Please notify.

    Thank you!

    I finished this figure myself.

    XFA/JavaScript in my paper, I call a custom function that I have written and pass a string (or a string variable containing) my file path for that I would like to check:

    if(typeof(MJS_FileExists) == "function") {
        try {
            if(MJS_FileExists("/C/something/somethingelse/filetocheckfor.pdf") == true) {
                xfa.host.messageBox("file is there");
            } else {
                xfa.host.messageBox("file is NOT there");
            }
        }
        catch(e) {
            app.alert("Processing error: "+e)
        }
    }
    

    The function I call is a folder level javascript.   You have to maybe do some Googleing on how and where to install them.   In the my file .js file real javascript level where the function is housed I use:

    var MJS_FileExists = app.trustedFunction(function(filename) {
        app.beginPriv();
        var existingDoc = false;
        try {
             var checkDoc = app.openDoc(filename);
             checkDoc.closeDoc();
         existingDoc = true;
        } catch(e) {
         existingDoc = false;
        }
        return existingDoc;
        app.endPriv();
    });
    

    It took me a lot of trial and error.  It sucks there is not a lot of in on the internet on how to do it via Acrobat / Live Cycle.   Hope this helps someone else.

  • How to check the data file is set to unlimilted autoextend

    S/N,

    Oracle version: 10.2.0.4
    OS: linux

    could someone tell me how can I check the data file are set to unlimited autoextend?

    Thank you
    Bahadur.

    Salvation;

    Pelase see:
    How to check the CanGrow data files the value of Maxsize unlimited [ID 468096.1]

    Respect of
    HELIOS

  • How to check what data file have been saved?

    Hello

    I take the level 0 with RMAN incremental backup... How to check if the data files are backed up or not? When this data file have been saved? If this data file backup not more than ten days... Need to backup data files?

    Help, please

    check v$ backup_datafile.COMPLETION_TIME

    HTH

  • How to check if an Excel Application is open, and if so to close before running a labview VI

    Hi all

    I have a VI that takes measures and store them in one worksheet Excel after a few digital manipulations. I was very careful to close whatever it is in the correct order before making a "Quit Application" at the end of the Labview VI

    The VI works well and as many times as we want as long as no Excel application has been left open (open hand to check the data for example) before running the labview VI.

    So currently, I have to be careful that no Excel application is open before starting the VI.

    Someone can tell me how my Labview VI can detect (at startup) If an Excel application is already open, and then close in case Yes?

    Thank you

    Youki

    Here you go,

    see you soon

  • How to create a new file when I open a folder?

    original title: Stupid Question... The files and folder, how can I

    Create a new file when I open a folder?  I use Windows 7, Microsoft Office Word 2003.

    In Vista when you are in a folder, you just went to the file, new, and created a new file but Windows 7 won't let you do.

    Thanks for any help.  THE

    Right-click in the folder and select new.
    Kind regards
    Hank Arnold
    Microsoft MVP
    Windows Server - Directory Services
    http://it.Toolbox.com/blogs/personal-PC-Assistant/

    05/07/2010 17:16, lead foot wrote:

    Create a new file when I open a folder?  I use Windows 7, Microsoft Office Word 2003.

    In Vista when you are in a folder, you just went to the file, new, and created a new file but Windows 7 won't let you do.

    Thanks for any help.  THE

    Best regards, Hank Arnold (MVP - DS)

  • How can I configure Firefox to check if a session is already open before you start a new?

    I have an elderly parent who always dbl_clks desktop icon when he wants to join his social media site, even if he never sold the last of his window he ran. The result is that there soon several windows ff running the same (like 20-30) while Windows allows more. I would like to put something so that when they click the icon on the desktop, it checks to see if ff is already running, and if so, it's just max that window.

    Thank you...

    Another possibility would be to add-no.-line switch remote control in combination with the current profile of the command line in the shortcut to the desktop (-no - remote 'profile name' Pei).

    Then you get a message that the profile is already in use when this icon is clicked, another time while Firefox is already running.
    This could be confusing if.

    This switch is normally used to open multiple windows of Firefox with a separate profile.

  • How to check if a file exists on target RT

    Hello

    I wonder y at - there a way to check if there is a file on target RT? Thank you!

    Tom

    You mean from the host? You can use the FTP functions. "FTP Get path Info.vi" returns error code 550 if a file is not but a code of success if he finds. You can also check the output of "path info". The type will tell you unknown if there isn't but the file if it is there.

  • How to check if a file closes

    Is there a a way to check if an external file exists using javascript?

    The doc.importDataObject returns false if a file exist and true if it does. You can later remove it if this is the case, using the doc.removeDataObject method.

  • In Flash CC how I convert/save the file to be opened in CS3?

    Fourms, please help me. I was just on the phone with a representative of the adobe customer service where I asked this very question which gives information:

    "I'm a host that uses flash CC. My 'customer' has cs3 and asks me to send the flash file for a test that I do for them. They can't open Flash CC or CS6. How to convert my file in CC? »

    He had the nerve to tell me that my 'customer' needs to upgrade. As he tries to sell me the idea that I should tell them to upgrade. Jesus Christ, Adobe.

    My client will not be upgraded and it's too expensive for me to try to buy someone online flash cs3 program. Can someone help me find a way I can send them my file?

    You can save up to older versions (back to CS5) with CS6 if you have access to it.

  • Cannot make the database - file is already opened in another application - unusable Fireworks

    I use CC for mac and when you try to export an image in Fireworks I get this message to appear...

    Screen Shot 2014-10-07 at 11.57.33.png

    He is constantly happening and even if I click ok or press the ESC key I get a version repeatedly the Virgin of the pop-up window, and I can't export the image. It is rendered unusable Fireworks and Dreamweaver with lights, it is the application that I use quite well all the time is a considerable embarrassment.

    Can someone help get this resolved please?

    I seem to have found the cause by accident. I was running AVG anti-virus software but uninstalled and hey presto Fireworks seems to be back to normal.

Maybe you are looking for

  • 5s - no response from some contacts IPhone

    Bought Iphone 5s last week - all contacts have been transferred, but I'm no longer receive texts or emails from certain contacts. No idea why?

  • How to recover data from a backup of HP without HP Recovery recovery

    Have HP p6230f AMD processor under Windows 7 Home Premium desktop unit.  Got infected with a Trojan horse really serious and it has corrupted so badly, it wouldn't boot Windows.  I did not have a recovery disc and can't find not all disks containing

  • Cannot access Windows 7 after upgrading ram?

    I have a Toshiba satellite c670 - 10 p and bought 8 GB of ram for it (2 x 4 GB) and now I can't start Windows 7. I thought it might just be something in the settings of windows that was wrong, so I started my transplanted live USB (it worked well) an

  • Merge to panorama in Lightroom 6:

    is it possible to export a different format than DNG? When it is saved to Lightroom DNG is not editable.

  • Force the VM to use the wired ethernet port instead of wireless

    HelloI use ver 9 workstation.  I have my host computer (win 7 64 bit) connected to our network of offices using the connection with wireless computers.I use a windows xp based virtual machine image that connects to devices of 3rd party via the ethern