file access denied under windows8

Hi Experts
One of my customer got windows8 os . The following code works okay under all other OS but windows8 causing a problem.


use in select("mastemp")

use mastemp in 101

if I try to close the open file and then open it again immediately

I have the error no 1705 and message File Access Denied.
Please help
Thanks
b001Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
Why don't you simply use a cursor?

As a general hint: Don't use sepcific work area numbers. Has nothing to do with the specific problem, but it might close something else you don't want to close. You hardly can keep track of all workarea numbers used. Simply use 0 as placeholder for any free workarea and address workareas with the alias names = table names opened in them.

Replace all your code with

Use In Select("Mastemp") && close Mastemp, if it's open
If !Used("invoice_str")
   Use invoice_str In 0 && use invoice_str.dbf, if it's not already open
Endif
* create a cursor with structure of invoce_str:
SELECT * FROM invoic_str WHERE .F. INTO Cursor MasTEMP ReadWrite.

Open in new window

After that you can write to MasTEMP, as if it was a DBF, so all other code can stay.

Bye, Olaf.
0
 
pcelbaCommented:
It can be anything... The first step they should do is to disable antivirus software and test again. Then it could be caused by write caching. Etc.

What folder is used for this file? Local, local with higher security, network? And why do you use hardcoded work area number? (OK, this does not have impact to this error probably.)

The work around:
IF !USED("mastemp")
  use mastemp in 101
ENDIF
0
 
Olaf DoschkeSoftware DeveloperCommented:
If you close and reopen to flush any cached data, there is FLUSH FORCE for that.

Indeed the closeing of a file can triger Virus Software to immediately open the file for checking it's content for virus signatures and then you don't get access, even though you had it right before.

If you ask me, even with defining DBF file extension as an execption for scanning, Windows takes longer to free file handles and reopening files may fail, you better not do that any more.

Bye, Olaf.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
b001Author Commented:
Hi Olaf
In my invoice application, I have this mastemp table which collects all the information just before preview or print invoice. Normally what I am doing every time just before preview or printing,
I close this file
then I copy structure from an other file with same structure
then open it and save latest data to it.

is there another better way of doing this.

Thanks
0
 
Olaf DoschkeSoftware DeveloperCommented:
What you're saying and what you're doing are two different things.

You close and open the same table. The only purpose I see is you want to ensure buffers are written. You already got two ways for that matter.

So in more detail, what are you doing? More code. Which line really fails?

Bye, Olaf.
0
 
b001Author Commented:
Hi Olaf

every time I add a sales line I update Mastemp table and update all the relative variables .
rather than delete and pack, I decided to do the following

this is my code


Use In Select("Mastemp")
If !Used("Mastemp")
      If !Used("invoice_str")
            Use invoice_str In 50
      Endif
      Sele invoice_str
      Set Safety Off
      Copy Stru To Sys(5)+Sys(2003)+'\temp\Mastemp.dbf'
      Set Safety On
  use  SYS(5)+SYS(2003)+'\temp\Mastemp.dbf' excl in 101
Endif

at the moment I donot know exactly which line fails. I will try to find out when I get next error. It only happens on one machine that is running Windows8 OS.
0
 
Olaf DoschkeSoftware DeveloperCommented:
Also:

If you don't CD somewhere specific, SYS(5)+SYS(2003) is the application directory. You can't write there. It's a write protected system directory. The moment you write into your application directory is at setup time, not at runtime. The application folder is for executables, read only files being executed. Configuration data etc. goes into appdata for single or all users, local or roaming. Depends on your need. Application main data can also go there or on a network share for multi user apps.

There are windows developer guides. Look back into guides for Vista and Win7, things changed mostly at the transition from XP to Vista. Windows security got more strict.

Bye, Olaf.

Edit:As I understand it, your code does not fail all the time and maybe only on Windows8, bu anyway, an application directory is a sensitive area, where newly written files are inspected more frequently and faster than in other directories. Application directories are, where executables are installed and so are more sensitive to virus infection, so they are watched and monitored more strictly. Using cursors you write to the users temp folder anyway, which is intended for temp files. It's also cleaned auomatically.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.