Index: trunk/Include/Classes/System/IO/File.ab
===================================================================
--- trunk/Include/Classes/System/IO/File.ab	(revision 435)
+++ trunk/Include/Classes/System/IO/File.ab	(revision 466)
@@ -4,40 +4,40 @@
 
 Enum FileAccess
-	Read = -2147483648 'GENERIC_READ
-	ReadWrite = -1073741824 'GENERIC_READ Or GENERIC_WRITE
-	Write = 1073741824' GENERIC_WRITE
+	Read      = GENERIC_READ
+	ReadWrite = GENERIC_READ Or GENERIC_WRITE
+	Write     = GENERIC_WRITE
 End Enum
 
 Enum FileAttributes
-	Archive           = 32 'FILE_ATTRIBUTE_ARCHIVE
-	Compressed        = 2048 'FILE_ATTRIBUTE_COMPRESSED
-	Device            = 64 'FILE_ATTRIBUTE_DEVICE
-	Directory         = 16 'FILE_ATTRIBUTE_DIRECTORY
-	Encrypted         = 16384 'FILE_ATTRIBUTE_ENCRYPTED
-	Hidden            = 2 'FILE_ATTRIBUTE_HIDDEN
-	Normal            = 128 'FILE_ATTRIBUTE_NORMAL
-	NotContentIndexed = 8192 'FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
-	Offline           = 4096 'FILE_ATTRIBUTE_OFFLINE
-	ReadOnly          = 1 'FILE_ATTRIBUTE_READONLY
-	ReparsePoint      = 1024 'FILE_ATTRIBUTE_REPARSE_POINT
-	SparseFile        = 512 'FILE_ATTRIBUTE_SPARSE_FILE
-	System            = 4 'FILE_ATTRIBUTE_SYSTEM
-	Temporary         = 256 'FILE_ATTRIBUTE_TEMPORARY
+	Archive           = FILE_ATTRIBUTE_ARCHIVE
+	Compressed        = FILE_ATTRIBUTE_COMPRESSED
+	Device            = FILE_ATTRIBUTE_DEVICE
+	Directory         = FILE_ATTRIBUTE_DIRECTORY
+	Encrypted         = FILE_ATTRIBUTE_ENCRYPTED
+	Hidden            = FILE_ATTRIBUTE_HIDDEN
+	Normal            = FILE_ATTRIBUTE_NORMAL
+	NotContentIndexed = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
+	Offline           = FILE_ATTRIBUTE_OFFLINE
+	ReadOnly          = FILE_ATTRIBUTE_READONLY
+	ReparsePoint      = FILE_ATTRIBUTE_REPARSE_POINT
+	SparseFile        = FILE_ATTRIBUTE_SPARSE_FILE
+	System            = FILE_ATTRIBUTE_SYSTEM
+	Temporary         = FILE_ATTRIBUTE_TEMPORARY
 End Enum
 
 Enum FileMode
-	Append = 4 'OPEN_ALWAYS
-	Create = 2 'CREATE_ALWAYS
-	CreateNew = 1 'CREATE_NEW
-	Open = 3 'OPEN_EXISTING
-	OpenOrCreate = 4 'OPEN_ALWAYS
-	Truncate = 5 'TRUNCATE_EXISTING
+	Append       = OPEN_ALWAYS
+	Create       = CREATE_ALWAYS
+	CreateNew    = CREATE_NEW
+	Open         = OPEN_EXISTING
+	OpenOrCreate = OPEN_ALWAYS
+	Truncate     = TRUNCATE_EXISTING
 End Enum
 
 Enum FileShare
-	None = 0
-	Read = FILE_SHARE_READ
-	Write = FILE_SHARE_WRITE
-	ReadWrite = FILE_SHARE_READ Or FILE_SHARE_WRITE
+	None       = 0
+	Read       = FILE_SHARE_READ
+	Write      = FILE_SHARE_WRITE
+	ReadWrite  = FILE_SHARE_READ Or FILE_SHARE_WRITE
 	DeleteFile = FILE_SHARE_DELETE
 End Enum
@@ -46,7 +46,11 @@
 Public
 
-	Static Sub AppendAllText( path As String, contents As String )
-		' TODO: 実装
-	End Sub
+	'----------------------------------------------------------------
+	' パブリック　メソッド
+	'----------------------------------------------------------------
+
+/*	Static Sub AppendAllText( path As String, contents As String )
+		' TODO: 実装
+	End Sub*/
 
 /*	Static Sub AppendAllText( path As String, contents As String, encoding As Encoding )
@@ -54,23 +58,25 @@
 	End Sub */
 
-	Static Function AppendText( path As String ) As StreamWriter
-		' TODO: 実装
-	End Function
+/*	Static Function AppendText( path As String ) As StreamWriter
+		' TODO: 実装
+	End Function*/
 
 	Static Sub Copy( sourceFileName As String, destFileName As String )
-		' TODO: 実装
+		Copy(sourceFileName, destFileName, False)
 	End Sub
 
 	Static Sub Copy( sourceFileName As String, destFileName As String, overwrite As Boolean )
-		' TODO: 実装
+		If Not CopyFile(Path.GetFullPath(sourceFileName), Path.GetFullPath(destFileName), overwrite) Then
+			Throw New IOException( "FileInfo: Failed to CopyFile." )
+		End If
 	End Sub
 
 	Static Function Create( path As String ) As FileStream
-		' TODO: 実装
-	End Function
-
-	Static Function Create( path As String, bufferSize As Long ) As FileStream
-		' TODO: 実装
-	End Function
+		Return New FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite)
+	End Function
+
+/*	Static Function Create( path As String, bufferSize As Long ) As FileStream
+		' TODO: 実装
+	End Function */
 
 /*	Static Function Create( path As String, bufferSize As Long, options As FileOptions ) As FileStream
@@ -82,22 +88,32 @@
 	End Function */
 
-	Static Function CreateText( path As String ) As StreamWriter
-		' TODO: 実装
-	End Function
-
-	Static Sub Decrypt( path As String )
-		' TODO: 実装
-	End Sub
-
-	Static Sub DeleteFile( path As String )
-		' TODO: 実装
-	End Sub
-
-	Static Sub Encrypt( path As String )
-		' TODO: 実装
-	End Sub
+/*	Static Function CreateText( path As String ) As StreamWriter
+		' TODO: 実装
+	End Function*/
+
+/*	Static Sub Decrypt( path As String )
+		' TODO: 実装
+	End Sub*/
+
+	Static Sub Delete( path As String )
+		If Not DeleteFile(path) Then
+			Throw New IOException("File.Delete: Failed to DeleteFile.")
+		End If
+	End Sub
+
+/*	Static Sub Encrypt( path As String )
+		' TODO: 実装
+	End Sub*/
 
 	Static Function Exists( path As String ) As Boolean
-		' TODO: 実装
+		Dim data As WIN32_FIND_DATA
+		Dim hFind = FindFirstFile(ToTCStr(path), data)
+		FindClose(hFind)
+
+		If hFind <> INVALID_HANDLE_VALUE Then
+			Return True
+		Else
+			Return False
+		End If
 	End Function
 
@@ -111,62 +127,64 @@
 
 	Static Function GetAttributes( path As String ) As FileAttributes
-		' TODO: 実装
+		Return New FileAttributes(getFileData(path).dwFileAttributes As Long, "FileAttributes")
 	End Function
 
 	Static Function GetCreationTime( path As String ) As DateTime
-		' TODO: 実装
+		Return System.DateTime.FromFileTime(getFileData(path).ftCreationTime)
 	End Function
 
 	Static Function GetCreationTimeUtc( path As String ) As DateTime
-		' TODO: 実装
+		Return System.DateTime.FromFileTimeUtc(getFileData(path).ftCreationTime)
 	End Function
 
 	Static Function GetLastAccessTime( path As String ) As DateTime
-		' TODO: 実装
+		Return System.DateTime.FromFileTime(getFileData(path).ftLastAccessTime)
 	End Function
 
 	Static Function GetLastAccessTimeUtc( path As String ) As DateTime
-		' TODO: 実装
+		Return System.DateTime.FromFileTimeUtc(getFileData(path).ftLastAccessTime)
 	End Function
 
 	Static Function GetLastWriteTime( path As String ) As DateTime
-		' TODO: 実装
+		Return System.DateTime.FromFileTime(getFileData(path).ftLastWriteTime)
 	End Function
 
 	Static Function GetLastWriteTimeUtc( path As String ) As DateTime
-		' TODO: 実装
+		Return System.DateTime.FromFileTimeUtc(getFileData(path).ftLastWriteTime)
 	End Function
 
 	Static Sub Move( sourceFileName As String, destFileName As String )
-		' TODO: 実装
+		If Not MoveFile(Path.GetFullPath(sourceFileName), Path.GetFullPath(destFileName)) Then
+			Throw New IOException("File.Move: Failed to MoveFile.")
+		End If
 	End Sub
 
 	Static Function Open( path As String, mode As FileMode ) As FileStream
-		' TODO: 実装
+		Return New FileStream(path, mode)
 	End Function
 
 	Static Function Open( path As String, mode As FileMode, access As FileAccess ) As FileStream
-		' TODO: 実装
+		Return New FileStream(path, mode, access)
 	End Function
 
 	Static Function Open( path As String, mode As FileMode, access As FileAccess, share As FileShare ) As FileStream
-		' TODO: 実装
+		Return New FileStream(path, mode, access, share)
 	End Function
 
 	Static Function OpenRead( path As String ) As FileStream
-		' TODO: 実装
-	End Function
-
-'	Static Function OpenText( path As String ) As StreamReader
-		' TODO: 実装
-'	End Function
+		Return Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)
+	End Function
+
+	Static Function OpenText( path As String ) As StreamReader
+		Return New StreamReader(path)
+	End Function
 
 	Static Function OpenWrite( path As String ) As FileStream
-		' TODO: 実装
-	End Function
-
-	Static Function ReadAllBytes( path As String ) As *Byte
-		' TODO: 実装
-	End Function
+		Return Open(path, FileMode.Open, FileAccess.Write)
+	End Function
+
+/*	Static Function ReadAllBytes( path As String ) As *Byte
+		' TODO: 実装
+	End Function*/
 
 /*	Static Function ReadAllLines( path As String ) As Strings
@@ -178,7 +196,7 @@
 	End Function */
 
-	Static Function ReadAllText( path As String ) As String
-		' TODO: 実装
-	End Function
+/*	Static Function ReadAllText( path As String ) As String
+		' TODO: 実装
+	End Function*/
 
 /*	Static Function ReadAllText( path As String, encoding As Encoding ) As String
@@ -186,11 +204,11 @@
 	End Function */
 
-	Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String )
-		' TODO: 実装
-	End Sub
-
-	Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean )
-		' TODO: 実装
-	End Sub
+/*	Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String )
+		' TODO: 実装
+	End Sub*/
+
+/*	Static Sub Replace( sourceFileName As String, destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean )
+		' TODO: 実装
+	End Sub*/
 
 /*	Static Sub SetAccessControl( path As String, fileSecurity As FileSecurity )
@@ -199,34 +217,42 @@
 
 	Static Sub SetAttributes( path As String, fileAttributes As FileAttributes )
-		' TODO: 実装
+		If Not SetFileAttributes(ToTCStr(path), fileAttributes) Then
+			Throw New IOException("File.SetAttributes: Failed to SetFileAttributes.")
+		End If
 	End Sub
 
 	Static Sub SetCreationTime( path As String, creationTime As DateTime )
-		' TODO: 実装
-	End Sub
-
-	Static Sub SetCreationTimeUtc( path As String, creationTime As DateTime )
-		' TODO: 実装
+		SetCreationTimeUtc(path, creationTime)
+	End Sub
+
+	Static Sub SetCreationTimeUtc( path As String, creationTimeUtc As DateTime )
+		Dim hFile = createFileToSetTime(path) As HANDLE
+		SetFileTime(hFile, creationTimeUtc.ToFileTimeUtc(), ByVal 0, ByVal 0)
+		CloseHandle(hFile)
 	End Sub
 
 	Static Sub SetLastAccessTime( path As String, lastAccessTime As DateTime )
-		' TODO: 実装
+		SetLastAccessTimeUtc(path, lastAccessTime)
 	End Sub
 
 	Static Sub SetLastAccessTimeUtc( path As String, lastAccessTimeUtc As DateTime )
-		' TODO: 実装
+		Dim hFile = createFileToSetTime(path) As HANDLE
+		SetFileTime(hFile, ByVal 0, lastAccessTimeUtc.ToFileTimeUtc(), ByVal 0)
+		CloseHandle(hFile)
 	End Sub
 
 	Static Sub SetLastWriteTime( path As String, lastWriteTime As DateTime )
-		' TODO: 実装
+		SetLastWriteTimeUtc(path, lastWriteTime)
 	End Sub
 
 	Static Sub SetLastWriteTimeUtc( path As String, lastWriteTimeUtc As DateTime )
-		' TODO: 実装
-	End Sub
-
-	Static Sub WriteAllBytes( path As String, bytes As *Byte )
-		' TODO: 実装
-	End Sub
+		Dim hFile = createFileToSetTime(path) As HANDLE
+		SetFileTime(hFile, ByVal 0, ByVal 0, lastWriteTimeUtc.ToFileTimeUtc())
+		CloseHandle(hFile)
+	End Sub
+
+/*	Static Sub WriteAllBytes( path As String, bytes As *Byte )
+		' TODO: 実装
+	End Sub*/
 
 /*	Static Sub WriteAllLines( path As String, contents As Strings )
@@ -238,7 +264,7 @@
 	End Sub */
 
-	Static Sub WriteAllText( path As String, contents As String )
-		' TODO: 実装
-	End Sub
+/*	Static Sub WriteAllText( path As String, contents As String )
+		' TODO: 実装
+	End Sub*/
 
 /*	Static Sub WriteAllText( path As String, contents As String, encoding As Enconding )
@@ -246,4 +272,28 @@
 	End Sub */
 
+Private
+
+	Static Function getFileData(path As String) As WIN32_FIND_DATA
+		Dim data As WIN32_FIND_DATA
+		Dim hFind = FindFirstFile(ToTCStr(Path.GetFullPath(path)), data)
+		FindClose(hFind)
+
+		If hFind <> INVALID_HANDLE_VALUE Then
+			Return data
+		Else
+			Throw New IOException("File.getFileData: Failed to FindFirstFile.")
+		End If
+	End Function
+
+	Static Function createFileToSetTime(path As String) As HANDLE
+		Dim hFile As HANDLE
+		hFile = CreateFile(ToTCStr(path), GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0)
+		If hFile = INVALID_HANDLE_VALUE Then
+			CloseHandle(hFile)
+			Throw New IOException("File.setFileTime: Failed to CreateFile.")
+			Exit Function
+		End If
+		Return hFile
+	End Function
 End Class
 
