天天看點

修改檔案屬性

實作效果:

  

修改檔案屬性

知識運用:

  FileInfo類的Attribute屬性    //擷取或設定檔案的屬性

private void button1_Click(object sender, EventArgs e)
        {
           System.IO.FileInfo file=new System.IO.FileInfo(textBox1.Text);
            if (checkBox1.Checked == true) {
                file.Attributes = System.IO.FileAttributes.ReadOnly;
            }else if (checkBox2.Checked == true){
                file.Attributes = System.IO.FileAttributes.System;
            }else if (checkBox3.Checked == true){
                file.Attributes = System.IO.FileAttributes.Archive;
            }else if (checkBox4.Checked == true){
                file.Attributes = System.IO.FileAttributes.Hidden;
            }
        }
      

繼續閱讀