Solved

file access denied under windows8

Posted on 2014-01-20
7
877 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 41

Expert Comment

by:pcelba
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 29

Expert Comment

by:Olaf Doschke
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Memo window in FoxPro 2 509
Translate dll vb.net code to VFP 9 10 694
Print a word document in Visual Foxpro 1 506
file (PDF) to base64 string 2 125
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…
A procedure for exporting installed hotfix details of remote computers using powershell
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

771 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

10 Experts available now in Live!

Get 1:1 Help Now