Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Attributes

Status
Not open for further replies.

ChrisAgius

Programmer
Sep 27, 2000
51
MT
How can I change the file attributes of a file from within my application. The file is Read-Only and I need to remove the Read-Only only a file.....

I also have another problem what Visual Fox files do I need when I install my application.

One last thing thing .... I am searching for a tool that has the same funtionality as the Visual Foxpro Command window where you can execute commands even if do not have foxpro installed on the Machine..

Thanks A lot Guys.

 
Well you can change the attribute to Writeable with the command
RUN ATTRIB -R filename

But be aware that this is a DOS command which will be executed in a dos box and windows is continuing the program.
This means that before you do anything with the file you first have to check that the read-only attribute is set off.

 
Some more ideas on setting a file-attribute...

- FILER.DLL (see the MSDN, topic 'filer')
Filer is installed with the VFP development environment.
The MSDN contains a full description, and in ...\VFP98\Tools\Filer you'll find an example form
(note: the examples may not be distributed)

- Using the FileSystemObject of the Windows Scripting Host
It works like this:
Code:
[ignore]*!* Init the File System Object
oFSO = CREATEOBJECT("Scripting.FileSystemObject")
*!* Grap a reference to the file
oFile = oFSO.GetFile("C:\MyData\MyFile.txt")
*!* do something with them attributes
*!* The property 'attributes' is read/write
*!* NOTE: this works with the Windows attribute flags:
*!* #DEFINE READONLY   1
*!* #DEFINE HIDDEN     2
*!* #DEFINE SYSTEM     4
*!* #DEFINE DIRECTORY 16
*!* Toggle using the VFP Bitwise functions..
oFile.Attributes = BITXOR(oFile.Attributes, READONLY)[/ignore]

For more information on the WSH: check out in the Newsletters a series on the WSH has been published by George Tasker and Ed Rauh
Diederik Vermeeren
verm1864@exact.nl
 
For file attributes, see: thread184-33016

For VFP runtime issue, see: thread184-26569 (amongst a million others)

For a command window emulator, see: thread184-13772 & thread184-25210

or visit:
Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top