2011-12-01 52 views

回答

1

使用File對象

的IsReadOnly屬性從MSDN(http://msdn.microsoft.com/en-us/library/system.io.fileinfo.isreadonly.aspx):

// Sets the read-only value of a file. 
    public static void SetFileReadAccess(string FileName, bool SetReadOnly) 
    { 
     // Create a new FileInfo object. 
     FileInfo fInfo = new FileInfo(FileName); 

     // Set the IsReadOnly property. 
     fInfo.IsReadOnly = SetReadOnly; 

    } 
相關問題