■■■

2016年4月9日土曜日

フォルダの属性を判定する方法(隠しフォルダ)

VisualC#2013パーフェクトマスター (Perfect Master SERIES)
フォルダの属性を判定する方法(隠しフォルダ)
VB.NET
        ' 初期化
        Dim uAttribute As System.IO.FileAttributes = System.IO.File.GetAttributes("C:\att\")

        ' フォルダであるか判定する
        If (uAttribute And System.IO.FileAttributes.Directory) = System.IO.FileAttributes.Directory Then
            Console.WriteLine("this is a folder")
        End If

        ' 隠しフォルダか判定する方法
        If (uAttribute And System.IO.FileAttributes.Hidden) = System.IO.FileAttributes.Hidden Then
            Console.WriteLine("this folder is hidden")

        End If

VisualC#2013パーフェクトマスター (Perfect Master SERIES)
C#
            // 初期化
            System.IO.FileAttributes uAttribute = System.IO.File.GetAttributes(@"C:\att\");

            // フォルダであるか判定する
            if ((uAttribute & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
            {
                Console.WriteLine("this is a folder");
            }

            // 隠しフォルダか判定する方法
            if ((uAttribute & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden)
            {
                Console.WriteLine("this folder is hidden");

            }
VisualC#2013パーフェクトマスター (Perfect Master SERIES)
■■■