Solved

file access denied under windows8

Posted on 2014-01-20
7
886 Views
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
Thanks
0
Comment
Question by:b001
  • 4
  • 2
7 Comments
 
LVL 42

Expert Comment

by:pcelba
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
ENDIF
0
 
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.
0
 

Author Comment

by:b001
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.

Thanks
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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.
0
 

Author Comment

by:b001
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
      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
 
LVL 29

Accepted Solution

by:
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
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
 
LVL 29

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

830 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