C#如何创建文件夹(隐藏的)?

解决方案 »

  1.   

    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);
            }
        }
    }
      

  2.   

    System.IO.File.SetAttributes("文件全路径", System.IO.FileAttributes.Hidden &System.IO.FileAttributes.System);