>I have been attempting to simplify some of my upgrades by simply writing the files for the upgrade onto the CD then have the client use the Windows Explorer to copy the files to the Software Directory.
>
>I have found that the process of copying files to the CD seems to give the files the attribute of "Read Only" and this attribute stays with the files when they are copied to the customer's hard drive. Our software will not work properly unless we can get rid of the "Read Only" attribute.
>
>I have looked into the low level file handling of VFP and it seems to be related to Creating and Opening files but I can't seem to find anything in the help files on how to change a File Attribute programatically. The files I am trying to change are .dbf and .frx files.
>
>Has anyone come across this before and figured out a way around it?
>
>Mike Smith
Mike,
A routine to change attributes :
ChangeAttr('c:\myPath\myFile.txt')
function ChangeAttr
lparameters tcFileName, tlReadOnly, tlHidden, tlSystem
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
local lnNewAttr
lnNewAttr = iif(tlReadonly,FILE_ATTRIBUTE_READONLY,0)+;
iif(tlHidden,FILE_ATTRIBUTE_HIDDEN,0)+;
iif(tlSystem,FILE_ATTRIBUTE_SYSTEM,0)
declare integer SetFileAttributes in Win32API ;
string @ lpFileName, integer dwFileAttributes
declare integer GetFileAttributes in Win32API ;
string @ lpFileName
return ( SetFileAttributes(@tcFilename, ;
bitor(bitand(GetFileAttributes(@tcFilename),0xFFFFFFF8),lnNewAttr)) = 1)
For your case there are other alternatives though.ie:
Create table Cargo (Filename m, Content m nocptrans)
insert into Cargo (FileName,Content) ;
values ('myDBF.dbf',FileToStr('myDBF.dbf'))
insert ...
So you'd only have a dbf and its fpt containing all of your files. To open it on target your exe would have (or possibly you'd prefer just to create a zip:) :
use Cargo
scan
StrToFile(Content,Filename)
endscan
Cetin