다음을 통해 공유


My.Application, My.Computer 및 My.User를 사용한 작업 수행

업데이트: 2007년 11월

정보 및 일반적으로 사용되는 기능에 대한 액세스를 제공하는 3개의 중심 My 개체는 My.Application 개체, My.Computer 개체My.User 개체입니다. 이러한 개체를 사용하여 현재 응용 프로그램, 응용 프로그램이 설치된 컴퓨터 또는 응용 프로그램의 현재 사용자에 관련된 정보에 각각 액세스할 수 있습니다.

My.Application, My.Computer 및 My.User

다음 예제에서는 My를 사용하여 정보를 검색하는 방법을 보여 줍니다.

' Displays a message box that shows the full command line for the
' application.
Dim args As String = ""
For Each arg As String In My.Application.CommandLineArgs
    args &= arg & " "
Next
MsgBox(args)
' Gets a list of subfolders in a folder
My.Computer.FileSystem.GetDirectories _
(My.Computer.FileSystem.SpecialDirectories.MyDocuments, True, "*Logs*")

정보 검색은 물론 이러한 3개의 개체를 통해 노출된 멤버를 사용하면 해당 개체와 관련된 메서드를 실행할 수 있습니다. 예를 들어, 다양한 메서드에 액세스하여 파일을 조작하거나 My.Computer를 통해 레지스트리를 업데이트할 수 있습니다.

파일, 디렉터리 및 드라이브를 조작하는 다양한 메서드와 특성이 포함된 My를 사용하면 파일 I/O가 훨씬 쉽고 빨라집니다. TextFieldParser 개체를 사용하면 구분되거나 너비가 고정된 필드가 있는 구조화된 대용량 파일에서 읽을 수 있습니다. 이 예제에서는 TextFieldParserreader를 열고 이 개체를 사용하여 C:\TestFolder1\test1.txt에서 읽습니다.

Dim reader As Microsoft.VisualBasic.FileIO.TextFieldParser
reader = My.Computer.FileSystem.OpenTextFieldParser _
("C:\TestFolder1\test1.txt")
reader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
reader.Delimiters = New String() {","}
Dim currentRow As String()
While Not reader.EndOfData
  Try
      currentRow = reader.ReadFields()
      Dim currentField As String
        For Each currentField In currentRow
            MsgBox(currentField)
        Next
        Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
          MsgBox("Line " & ex.Message & _
          "is not valid and will be skipped.")
    End Try
End While

My.Application을 사용하면 응용 프로그램에 대한 culture를 변경할 수 있습니다. 다음 예제에서는 이 메서드를 호출하는 방법을 보여 줍니다.

' Changes the current culture for the application to Jamaican English.
My.Application.ChangeCulture("en-JM")

참고 항목

개념

My가 프로젝트 형식에 의존하는 방식

참조

My.Application 개체

My.Computer 개체

My.User 개체