Error 1077. File Open: Open Failed
Keywords: Error 1077 File Open Failed
General Question on FileOpen:
I'm getting the 1077: FileOpen: Openfailed error during the second Call() pass of the first line of code below. I suspect that the FileClose() command is not executing at all, but I'm not aware of anyway to detect a successful FileClose(), nor do I know how to resolve. I have attempted TimeDelay() thinking that maybe it was a speed problem, but that does not help either. Any suggestions would be greatly appreciated.handle=FileOpen(tmpscrnfile,"WRITE") FileWrite(handle,crntscrn) ; TimeDelay(15) FileClose(handle) ; tmpscrnfile is a string containing a fully ; qualified path and file name. ; ; crntscrn is a string containing up to ; 3072 characters.Answer:
- Either the file is open by something else, or somehow the script is getting run twice or something.
- Add message statements at the fileopen and fileclose so you can see them happening.
- Try adding the FileExist to catch the problem in the act.
- Try turning:
Debug(1)on to single step the process.
- My belief is that FileClose works. The open failure is a result of not doing a previous file close, or the file being open by some other application. For example if you are running a program that uses the file, somehow that program still has its claws on it (Run? RunWait?)
- Here's a sample script to take a closer look at the situation.
Message("Test 1","Program Starting") fn="C:\temp\xxx.yyy" if FileExist(fn)==2 Message("EEEEK","File is open. Cannot open for write") exit endif handle=FileOpen(fn,"WRITE") FileWrite(handle,"some data") Message("Test 2","File is open") FileClose(handle) Message("Test 3","File is closed")Question on FileOpen and Compiling:
I'm getting this error message, when trying to recompile an EXE after a minor change in the WBT file, which from all appearances should not have caused any problems. I'm trying to compile to a network drive. Why is this happening?Answer:
When Compiler tries to compile a WBT, it compiles the file in memory, and then when it goes to write the EXE file, it will report this error message, "Error 1077. File Open: Open Failed," if the old EXE of the same name, and in the same path, is unwriteable.It could be unwriteable for a couple of reasons:
What to do? Change the target filename or target directory of the EXE file, in the third option in the main Compiler window. If you do this, and the compile is now successful, then you know that one of the conditions above exists, and you can now go about your business tidying things up.
- The EXE file is Read-Only; or
- There is a lock on the EXE file you are trying to write to; or
- The EXE is already executing. Compiler cannot write to a file that is currently active.
Question on FileOpen and Directory Names with Spaces:
I'm getting a 1077 error when I try something like this (under NT 4.0). fubar is a file. It chokes on the space in the "program file" directory name.zgsTempDir = "g:\temp\program files\fubar" zlifh = fileopen(zgsTempDir,"WRITE")The directory is accessible, no files are open, permissions are ok, etc.I need to do this since there is no such function to convert LFN directories into SFN ones without having to first create a file in the directory then do a FileNameShort to that file.
Answer:
Winbatch can indeed handle long file names.Are you using the 16 bit version of WinBatch??? The 16 bit version indeed cannot handle long files names. Only the 32 bit version can.
Article ID: W12937Filename: 1077 File Open Failed.txt