Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set file readonly
Message
From
04/12/2017 13:15:28
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Miscellaneous
Thread ID:
01656088
Message ID:
01656108
Views:
49
I dont wanted to update my previous answer and this is another code to solve your problem.
*change attribut of a file,folder...
*the old DOS attrib command can work  also on the file attribute
*to have the help on this command


Local m.lcfile
m.lcfile=Getfile()
If Empty(m.lcfile)
  Return .F.
Endi
*+R readonly attribut  -R read/write attribut
*best way to run with dos is to build a bat file to make  operation success.

Local m.myvar
TEXT to m.myvar textmerge noshow
ATTRIB  +R  "<<m.lcfile>>"
del asup.bat
ENDTEXT
Strtofile(m.myvar,"asup.bat")

&&shellexecute
Declare Integer ShellExecute In shell32.Dll ;
  INTEGER hndWin, ;
  STRING cAction, ;
  STRING cFileName, ;
  STRING cParams, ;
  STRING cDir, ;
  INTEGER nShowWin

Local m.result
m.result=ShellExecute(0,"open","asup.bat","","",0)
Messagebox("Result="+Trans(m.result),0+32+4096,'',1200)

If m.result>32
  Messagebox("Successfull...Rightclick on the selected file  and see properties at below (read only..hidden)",0+32+4096,2000)
  Local m.o
  m.o=Justpath(m.lcfile)
  Run/N explorer &o

  Local m.x
  m.x=Inputbox("Want help on attrib command ?","","yes")
  If m.x="yes"
    Run/N cmd.Exe Attrib /?
  Endi

Else
  Messagebox("An error was occured!  result="+Trans(m.result),16+4096)
Endi
*note : for attrib help can redirect the dos window in a txt file by adding to the command line ">yourfileTXT"
Adir() can retrieve the attribut of any file or folder (in column 5: A,H,R,S,D)
Previous
Reply
Map
View

Click here to load this message in the networking platform