Function to set ReadOnly to false

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Worm
    Indigo Rose Customer
    • Jul 2002
    • 3971

    Function to set ReadOnly to false

    This is a function to set the ReadOnly attribute to false on all files in folder and it's subfolder. Useful when you've copied files from a CD to the hard drive.

    Sample Call
    UndoReadOnly("C:\Program Files\My App")


    Global Function
    Code:
    function UndoReadOnly(sFolder)
    	local n;
    	local m_File;
    	
    	--find all files in the passed folder
    	m_tblFiles = File.Find(sFolder, "*.*", true, true, nil)
    	
    	if m_tblFiles ~= nil then
    		--setup the attribute table
    		attrib = {};
    		attrib.ReadOnly = false;
    		--enumerate table
    		for n, m_File in m_tblFiles do
    			--set attribute
    			File.SetAttributes(m_File, attrib);
    		end
    	end
    	
    	--clean up
    	attrib = nil;
    	m_tblFiles = nil;
    end
  • yosik
    Indigo Rose Customer
    • Jun 2002
    • 1858

    #2
    Thanks Worm. It can be very useful.
    There is also a small *.bat program that does that.
    Problem is that sometimes, you want/need some of the files to be read only and some not (example, backing up a project in Video Editing on some systems).
    I personally always zip the files/folders before burning them on CD. That way their attrib remain.
    If you zip the files/folders, you remain at the original states for all you files.
    Yossi

    Comment

    • TJ_Tigger
      Indigo Rose Customer
      • Sep 2002
      • 3159

      #3
      Originally posted by yosik

      Problem is that sometimes, you want/need some of the files to be read only and some not (example, backing up a project in Video Editing on some systems).
      Thats a good idea. You could add another parameter that could be passed to the function as a table where in the table would contain a list of files that you want to remain in the readonly state.

      tROFiles = {"File1.ext", "File2.ext", "File3.ext", "File4.ext"}
      UndoReadOnly("C:\Program Files\My App", tROFiles)
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment

      • davels
        Forum Member
        • Feb 2007
        • 43

        #4
        Thx, nice function

        Comment

        Working...
        X