Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


file access denied under windows8

Posted on 2014-01-20
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 43

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 30

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.

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

LVL 30

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 30

Accepted Solution

Olaf Doschke earned 2000 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 30

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In this article, I’ll show how research, determination, and use of modern technology helped me solve a DNA mystery.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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