非NTFS权限,在FAT32下也可用的,
也不是改文件的普通属性,
是怎么弄的??
也不是改文件的普通属性,
是怎么弄的??
解决方案 »
- 关于计时器不准的问题
- C#中类似这样的Fri Mar 25 14:38:23 +0800 2011时间格式要怎么转换成yyyy-MM-dd hh-mm-ss时间格式
- C#如何读取UTF-8网页?(例如谷歌)
- 错误:Cannot find KeycodeV2.dll, or invalid keycode.
- ++++++++刚学c#.net两个月,做了一个项目招聘网,请大家来批一下,感谢csdn,希望大家共同交流!++++++++++++
- 关于在不同控件事件中使用同一DATASET的问题
- 求知晓 .NET C# 常用的框架 技术
- ====大家讨论:为什么修改Z-Iindex对DropdownList不起作用?高手指点,在线。。。====
- c# win form 文本文件中的數據新增到數據庫...求解..............
- 关于字符串的问题。
- 请教SQL SERVER 2000数据库访问的简单问题!!!!!!1
- 用C#做好的网站程序怎么申请域名且发布到网上去?WebService 呢?请高手指教阿
更改里头的属性就可以,具体可以参考msdn
{ File.SetAttributes(@"c:\tempuploads\newFile.txt", FileAttributes.ReadOnly FileAttributes.Hidden); }
命名空间:System.IO
path
该文件的路径。
fileAttributes
所需的 FileAttributes,例如 Hidden、ReadOnly、Normal 和 Archive-------------------------------------------------
下面的示例通过将 Archive 和 Hidden 属性应用于文件,演示了 GetAttributes 和 SetAttributes 方法。
[Visual Basic]
Imports System
Imports System.IO
Imports System.TextPublic Class Test
Public Shared Sub Main()
Dim path As String = "c:\temp\MyTest.txt" ' Delete the file if it exists.
If File.Exists(path) = False Then
File.Create(path)
End If If (File.GetAttributes(path) And FileAttributes.Hidden) = FileAttributes.Hidden Then
' Show the file.
File.SetAttributes(path, FileAttributes.Archive)
Console.WriteLine("The {0} file is no longer hidden.", path) Else
' Hide the file.
File.SetAttributes(path, File.GetAttributes(path) Or FileAttributes.Hidden)
Console.WriteLine("The {0} file is now hidden.", path)
End If
End Sub
End Class
[C#]
using System;
using System.IO;
using System.Text;class Test
{
public static void Main()
{
string path = @"c:\temp\MyTest.txt"; // Delete the file if it exists.
if (!File.Exists(path))
{
File.Create(path);
} if ((File.GetAttributes(path) & FileAttributes.Hidden) == FileAttributes.Hidden)
{
// Show the file.
File.SetAttributes(path, FileAttributes.Archive);
Console.WriteLine("The {0} file is no longer hidden.", path); }
else
{
// Hide the file.
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
Console.WriteLine("The {0} file is now hidden.", path);
}
}
}
hidden还是可以用显示所有文件时看到的