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

2016-01-29 18:20 29 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

 

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

延伸阅读
打开文件夹 首先打开找到要设置密码的文件夹,并右键点击文件夹 添加到压缩文件 右键点击文件夹出现下拉菜单,在下拉菜单上面点击添加到压缩文件 选择高级 点击添加到压缩文件以后出现压缩文件名和参数窗口,点击窗口上面的高级 设置密码 点击高级以后进入高级设置页面,点击右侧的设置密码 确认 ...
如何将CAD文件转成JPG图片?   1、输入打印命令plot,在选择打印机时选择"zwcad virtual JPEG plotter.pc5打印机;如图所示: 2、选择好自已想要的图纸尺寸或输入个自定义的像素尺寸。 3、其它的设置和我们使用普通的打印机一样(打印样式,打印范围,比例等); 4、点击确定打印,接着弹出一个对话框,提示保存文件,把文...
代码如下: 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...
标签: ASP
  <% Function GetPage(url) dim Retrieval Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", url, False ', "", "" .Send GetPage = BytesToBstr(.ResponseBody) End With Set Retrieval = Nothing End Function Function BytesToBstr(body) dim objstream set objstream = Server.CreateObj...
如何将iPhone上的文件夹重叠   今天教大家一个iPhone隐藏的小技巧!那就是如何让文件夹重叠,在iOS9文件夹中创建子文件夹。 ①我们需要创建一个文件夹,或使用原有文件夹。 ②将母文件夹放在屏幕顶部图标第一排的第二个位置。 ③接下来,我们要用右手食指按住子文件夹,再用左手拇指点击屏幕顶部二三图标中间偏上空...

经验教程

479

收藏

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