Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File Attribute
Message
From
18/10/2002 07:43:05
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
17/10/2002 00:03:32
Mike Smith
Doncaster Office Services
Oakville, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00712181
Message ID:
00712779
Views:
14
>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') && Clear RO,Hidden,System

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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform