Imports System.Runtime.InteropServices
<DllImport("kernel32")> _
Private Shared Function CreateFile(lpFileName As String, dwDesiredAccess As UInteger, dwShareMode As UInteger, lpSecurityAttributes As IntPtr, dwCreationDisposition As UInteger, dwFlagsAndAttributes As UInteger, _
hTemplateFile As IntPtr) As IntPtr
<DllImport("kernel32")> _
Private Shared Sub CloseHandle(hObject As IntPtr)
Const CREATE_ALWAYS As UInteger = &H1
Const GENERIC_WRITE As UInteger = &H40000000
Const GENERIC_READ As UInteger = &H80000000UI
Public Shared Sub Main(args As String())
Dim hFile As IntPtr = CreateFile("C:\text.txt", GENERIC_READ Or GENERIC_WRITE, 0, IntPtr.Zero, CREATE_ALWAYS, CUInt(System.IO.FileAttributes.Normal), IntPtr.Zero)
If hFile <> IntPtr.Zero Then
Console.WriteLine("C 드라이브 밑에 test.txt 파일이 생성되었습니다.")
Console.WriteLine("File.Exists 실행 결과: {0}", System.IO.File.Exists("C:\test.txt"))
Console.WriteLine("파일을 만들지 못했습니다.")