다음을 통해 공유


ISEFile 객체

ISEFile 객체는 Windows PowerShell 통합 스크립팅 환경(ISE)의 파일을 나타냅니다. Microsoft.PowerShell.Host.ISE.ISEFile 클래스의 인스턴스입니다. 이 주제는 구성원 메서드와 구성원 속성을 나열합니다. $psISE.CurrentFile PowerShell 탭의 Files 컬렉션 내 와 파일은 모두 Microsoft.PowerShell.Host.ISE.ISEFile 클래스의 인스턴스입니다.

메서드

저장([저장인코딩] )

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

파일을 디스크에 저장합니다.

[saveEncoding] - 선택적 System.Text.Encoding 저장 파일에 사용할 선택적 문자 인코딩 매개변수. 기본 값은 UTF8입니다.

Exceptions

  • System.IO.IOException: 파일을 저장할 수 없었습니다.
# Save the file using the default encoding (UTF8)
$psISE.CurrentFile.Save()

# Save the file as ASCII.
$psISE.CurrentFile.Save([System.Text.Encoding]::ASCII)

# Gets the current encoding.
$myfile = $psISE.CurrentFile
$myfile.Encoding

SaveAs(파일명, [saveEncoding])

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

지정된 파일 이름과 인코딩으로 파일을 저장합니다.

파일네임 - 문자열 파일을 저장할 이름입니다.

[saveEncoding] - 선택적 System.Text.Encoding 저장 파일에 사용할 선택적 문자 인코딩 매개변수. 기본 값은 UTF8입니다.

Exceptions

  • System.ArgumentNullException: 파일명 매개변수가 null입니다.
  • System.ArgumentException: 파일명 매개변수가 비어 있습니다.
  • System.IO.IOException: 파일을 저장할 수 없었습니다.
# Save the file with a full path and name.
$fullpath = "C:\temp\newname.txt"
$psISE.CurrentFile.SaveAs($fullPath)
# Save the file with a full path and name and explicitly as UTF8.
$psISE.CurrentFile.SaveAs($fullPath, [System.Text.Encoding]::UTF8)

속성

디스플레이 이름

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

이 파일의 표시 이름을 포함하는 문자열을 가져오는 읽기 전용 속성입니다. 이름은 편집기 상단의 파일 탭에 표시됩니다. 이름 끝에 별표(*)가 붙으면 파일이 저장되지 않은 변경 사항이 있음을 나타냅니다.

# Shows the display name of the file.
$psISE.CurrentFile.DisplayName

Editor

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

지정된 파일에 사용되는 편집기 객체 를 가져오는 읽기 전용 속성입니다.

# Gets the editor and the text.
$psISE.CurrentFile.Editor.Text

인코딩

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

원본 파일 인코딩을 받는 읽기 전용 속성입니다. 이것은 System.Text.Encoding 객체입니다.

# Shows the encoding for the file.
$psISE.CurrentFile.Encoding

FullPath

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

열린 파일의 전체 경로를 지정하는 문자열을 얻는 읽기 전용 속성입니다.

# Shows the full path for the file.
$psISE.CurrentFile.FullPath

IsSaved

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

파일이 마지막으로 수정된 후에 저장되었을 때 반환 $true 되는 읽기 전용 불리언 속성입니다.

# Determines whether the file has been saved since it was last modified.
$myfile = $psISE.CurrentFile
$myfile.IsSaved

제목이 없어

Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.

파일에 제목이 부여된 적이 없을 때 반환 $true 하는 읽기 전용 속성입니다.

# Determines whether the file has never been given a title.
$psISE.CurrentFile.IsUntitled
$psISE.CurrentFile.SaveAs("temp.txt")
$psISE.CurrentFile.IsUntitled

또한 참조하십시오