如何将代码生成的文件设为只读

2016-01-29 18:20 23 1 收藏

如何将代码生成的文件设为只读,如何将代码生成的文件设为只读

【 tulaoshi.com - ASP 】

  Attributes Property
Sets or returns the attributes of files or folders. Read/write or read-only, depending on the attribute.

object.Attributes [= newattributes]

Arguments
object

Required. Always the name of a File or Folder object.

newattributes

Optional. If provided, newattributes is the new value for the attributes of the specified object.

Settings
The newattributes argument can have any of the following values or any logical combination of the following values:

Constant Value Description
Normal 0 Normal file. No attributes are set.
ReadOnly 1 Read-only file. Attribute is read/write.
Hidden 2 Hidden file. Attribute is read/write.
System 4 System file. Attribute is read/write.
Directory 16 Folder or directory. Attribute is read-only.
Archive 32 File has changed since last backup. Attribute is read/write.
Alias 1024 Link or shortcut. Attribute is read-only.
Compressed 2048 Compressed file. Attribute is read-only.


Remarks
Attempts to change any of the read-only attributes (Alias, Compressed, or Directory) are ignored.

When setting attributes, it is generally a good idea to first read the current attributes, then change the individual attributes as desired, and finally write the attributes back.

The following code illustrates the use of the Attributes property with a file:

Function ToggleArchiveBit(filespec)
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   If f.attributes and 32 Then
      f.attributes = f.attributes - 32
      ToggleArchiveBit = "Archive bit is cleared."
   Else
      f.attributes = f.attributes + 32
      ToggleArchiveBit = "Archive bit is set."
   End If
End Function

 

来源:https://www.tulaoshi.com/n/20160129/1505354.html

延伸阅读
代码如下: package com.qhdstar.java.pdf; import java.awt.Color; import java.io.FileOutputStream; import com.lowagie.text.Chapter; import com.lowagie.text.Document; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowag...
第一步:在电脑里面找两个记事本文件。 第二步:用鼠标右键点击这两个文件,在下拉菜单中找到添加到压缩文件。 第三步:出现压缩文件名和参数,在压缩方式下面选择存储,然后确定. ...
打开文件夹 首先打开找到要设置密码的文件夹,并右键点击文件夹 添加到压缩文件 右键点击文件夹出现下拉菜单,在下拉菜单上面点击添加到压缩文件 选择高级 点击添加到压缩文件以后出现压缩文件名和参数窗口,点击窗口上面的高级 设置密码 点击高级以后进入高级设置页面,点击右侧的设置密码 确认 ...
控制面板 首先,打开控制面板 默认程序 在所有控制面板项——》默认程序 点击设置 进入默认程序界面,点击第一个“设置默认程序”,这时候会加载电脑上的软件,如果软件安装的比较多,则需要等待一小会儿。 运行更改 点击谷歌浏览器,设置为默认选项,同时可以设置一下关联文件默认打开(设置默认的时候,一...
标签: 电脑入门
将电脑桌面上的文件夹与文件建立在D盘有很多好处,比如,重装系统的时候,桌面上的一些文本就不会丢了!我们只要把C:Documents and Settings里的你的用户名文件夹里的桌面文件夹剪切到任何你想要的地方即可。 具体如下:先在d盘建一个文件夹,然后点开始---〉运行---〉regedit,点击HKEY_CURRENT_USER--〉 Software--〉 Microsoft--〉Windows...

经验教程

679

收藏

93
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部