Created
July 1, 2015 20:46
-
-
Save Koki-Shimizu/86b1dab64b6cf319658a to your computer and use it in GitHub Desktop.
エクスプローラーで見れないフォルダ・ファイルの作り方(Windows/.NET/C#)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
namespace HiddenFolderMaker | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var path = @"C:\temp\hidden2\"; | |
Directory.CreateDirectory(path); | |
var directoryInfo = new DirectoryInfo(path); | |
directoryInfo.Attributes |= System.IO.FileAttributes.Hidden; | |
directoryInfo.Attributes |= System.IO.FileAttributes.System; | |
var filepath = Path.Combine(path, "naisyo.txt"); | |
File.CreateText(filepath); | |
var file_attr = File.GetAttributes(filepath); | |
File.SetAttributes(filepath,file_attr | FileAttributes.Hidden); | |
File.SetAttributes(filepath, file_attr | FileAttributes.System); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment