请帮忙

huangwentao658 2009-02-25 08:00:52
C#如何创建文件夹(隐藏的)?
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zgke 2009-02-25
  • 打赏
  • 举报
回复
System.IO.File.SetAttributes("文件全路径", System.IO.FileAttributes.Hidden &System.IO.FileAttributes.System);
zhaozhijun0207 2009-02-25
  • 打赏
  • 举报
回复
你这是创建txt吧
宝_爸 2009-02-25
  • 打赏
  • 举报
回复
using System;
using System.IO;
using System.Text;

class Test
{
public static void Main()
{
string path = @"c:\temp\MyTest.txt";

// Create the file if it does not exist.
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);
}
}
}

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧