Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Read Only Files
Message
From
25/02/1999 16:43:08
 
 
To
25/02/1999 16:17:08
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00191642
Message ID:
00191661
Views:
13
>Hi -
>
>I came across a problem when I use my form wizard to create forms for my application. I am getting an error message after after I complete the form wizard prompts and save the form. Error #111 pops up on the screen.
>
>Error #111 says "you attempted to write a file that was created or accessed for read only purposes"
>
>So, I went to may handy dandy FoxPro book and starting reading about read only files.
>
>My question is this:
>How should I set up my application so this isn't a problem, especially in the design phase? How do I tell FoxPro to make a program or file read only?
>
>Thanks for any comments/help in advance

You can change the File Attributes of a file programmatically within a VFP application by calling a Win32 API function named (strangely enough) SetFileAttributes(). There's a downloadable program here on UT that provides access to the necessary API; the code is pretty simple:
DECLARE INTEGER SetFileAttributes IN Kernel32 ;
	STRING cFileNameToAlter, ;
	INTEGER nAttributeMask
*       
*       attribute bit values are as follows;  this is a partial list.
*       You can set multiple attributes by adding the numbers together
*       for the attributes you want set, ie Read-only and hidden
*       would be 1 + 2 (3 unless you work in base 2, then it's 11)
*
*       You must explicitly set the attributes you want to have enabled.
*       If you have a file that's currently read-only, but now want it
*       to be read-only and hidden, you pass 3 for the second parameter,
*       but if you want it to be hidden but read-write you'd pass a 2,
*       clearing the 1 bit
*
*	R = Read-only   	1
*	H = Hidden		2
*	S = System		4
*	A = Archive		32 
*
*       Other attribute values can be found in the MSDN docs

nAttribs = 1  && read-only, to clear, use 0

IF SetFileAttributes(FULLPATH(cFileName), nAttribs) = 1
   * it worked
ELSE
   * it failed
ENDIF
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform