file access denied under windows8

Posted on 2014-01-20
Last Modified: 2014-01-25
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
Question by:b001
  • 4
  • 2
LVL 41

Expert Comment

ID: 39794071
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
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39803586
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.

Author Comment

ID: 39804115
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.

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

LVL 29

Expert Comment

by:Olaf Doschke
ID: 39805097
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.

Author Comment

ID: 39808524
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
      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

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.
LVL 29

Accepted Solution

Olaf Doschke earned 500 total points
ID: 39808532
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
* 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.
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39808545

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.

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: (http://msd…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now