C# Class NSoft.NFramework.IO.FileTool

显示文件 Open project: debop/NFramework

Public Methods

Method Description
Base64Encode ( string filepath ) : string

파일 내용을 읽어 Base64 형식의 문자열로 변환합니다.
Http Protocol에서는 이진 Data는 전송할 수 없으므로, Base64 Encoding 방식을 기본으로 사용한다.

Base64Encode ( this filepath, char &outArray ) : void

파일 내용을 읽어 Base64 형식의 문자열로 변환합니다.
Http Protocol에서는 이진 Data는 전송할 수 없으므로, Base64 Encoding 방식을 기본으로 사용한다.

ChangeFileAttributesToWritable ( this filename ) : void

File 속성을 쓰기 가능하도록 한다.

CompareVersion ( string version1, string version2 ) : int

두 버전을 비교한다.

CopyDirectory ( this srcPath, string destPath, bool overwrite = false ) : void

디렉토리 전체를 복사한다.

대상경로가 존재하지 않을 시에는 새로 만들어 사용한다.

CopyFile ( this srcFile, string destFile, bool overwrite = false ) : void

파일 복사

CreateDirectory ( this path ) : void

지정한 Directory가 존재하지 않는다면 새로 생성한다.

CreateEmptyFile ( this filePath ) : void

길이가 0인 파일을 만든다.

DeleteDirectory ( this path, bool recursive = true ) : void

지정된 Directory를 삭제한다. 해당 Directory에 속한 Sub Directory와 파일도 삭제 가능하다.

DeleteFile ( this filename, bool fireException = true ) : void

파일 삭제

DirectoryExists ( this path ) : bool

해당 디렉토리가 존재하는지 확인한다.

ExtractFileExt ( this path ) : string

경로 문자열에서 파일의 Extension 문자열만 추출한다.

ExtractFileName ( this path ) : string

경로 문자열에서 파일 이름에 해당하는 문자열만 추출한다.

ExtractFilePath ( this path ) : string

경로 문자열에서 Directory 명만 추출해 낸다.

FileExists ( this filename ) : bool

파일이 존재 하는지 검사하다.

FindNewFileName ( this filename ) : string

파일을 겹쳐쓰기를 방지하기위해 같은 이름의 파일이 있으면 새로운 파일 이름을 반환한다.

해당 파일을 찾고, 그 파일이 없으면 해당 파일명을 반환하고, 중복되는 파일명이 있으면 "FileName[1].ext" 와 같이 뒤에 인덱스를 붙여서 만든다.

GetBufferedFileStream ( string filename, FileOpenMode openMode ) : BufferedStream

파일 스트림을 데코레이션한 버퍼 스트림을 생성한다.

GetCurrentPath ( ) : string

Application 현재 폴더 (Path)를 구한다.

GetDirectories ( string path ) : string[]

해당 폴더를 기준으로 하위 폴더의 Path를 문자열 배열로 반환한다.

GetDirectories ( string path, string searchPattern ) : string[]

해당 폴더를 기준으로 검색 패턴과 일치하는 폴더를 검색한다.

GetDirectorySize ( this path, bool withSubDirectory ) : long

지정된 경로의 크기 (서브 디렉토리와 파일의 크기를 합산) 을 구한다.

GetFileCreateTime ( this filename ) : DateTime

파일의 생성 시간을 구한다.

GetFileLastWriteTime ( this filename ) : DateTime

파일에 마지막 Access한 시간

GetFileSize ( this filename ) : long

해당 파일의 크기를 구한다.

GetFileStream ( string filename, FileOpenMode openMode ) : FileStream

파일 스트림 System.IO.FileStream을 생성해 준다.

GetFileSystemInfo ( this path ) : FileSystemInfo

지정한 경로의 파일시스템를 반환합니다.

GetFileVersion ( this filename ) : string

지정된 파일의 Version 정보를 반환한다.

GetFileVersionInfo ( this filename ) : FileVersionInfo

파일의 버전 정보를 구한다.

GetFiles ( string path ) : string[]

지정된 폴더에 있는 모든 파일의 이름을 배열로 반환한다.

GetFiles ( string path, string searchPattern ) : string[]

지정된 폴더에 있는 파일중에 검색 패턴과 일치하는 파일의 이름을 배열로 반환한다.

GetNewFileName ( this filename ) : string

파일을 겹쳐쓰기를 방지하기위해 지정된 파일명이 있다면, IE 처럼 파일명을 새로 생성한다.

해당 파일을 찾고, 그 파일이 없으면 해당 파일명을 반환하고, 중복되는 파일명이 있으면 "FileName[1].ext" 와 같이 뒤에 인덱스를 붙여서 만든다.

GetPhysicalPath ( this virtualPath ) : string

가상경로를 절대 경로로 계산한다.

GetProgramFilesPath ( ) : string

Windows Program Files 경로를 구한다. (C:\Program Files)

GetProgramsPath ( ) : string

Programs 폴더의 경로를 구한다. (C:\Documents and Settings\Administrator)

GetSpecialFolderPath ( this folder ) : string

Shell의 특정 폴더를 찾는다.
시스템 특수 폴더는 공용 정보가 들어 있는 Program Files, Programs, System 또는 Startup 등과 같은 폴더입니다. 특수 폴더는 Windows를 설치할 때 기본적으로 시스템에서 설정하거나 사용자가 명시적으로 설정합니다.

GetSystemPath ( ) : string

Windows System Directory의 경로를 구한다. (C:\Windows\System32)

GetTempFileName ( ) : string

고유한 임시 파일 이름을 반환하고, 디스크에 해당 이름으로 크기가 0 바이트인 파일을 만듭니다.

GetTempFileName ( this prefix ) : string

지정한 접두사로 고유한 임시 파일을 만들고, 디스크에 해당 이름으로 크기가 0 바이트인 파일을 만듭니다.

GetTempPath ( ) : string

시스템의 Temporary Directory를 반환한다. (C:\Documents and Settings\Administrator\Local Settings\Temp)

GetValidFileName ( this filename, string invalidReplacement = null, string spaceReplacement = null ) : string

지정된 파일 경로에 금칙 문자를 주어진 대체 문자열로 변경하여, 유효한 경로 문자열을 만든다.

GetValidPath ( this path, string invalidReplacement = null, string spaceReplacement = null ) : string

지정된 파일 경로에 금칙 문자를 주어진 대체 문자열로 변경하여, 유효한 경로 문자열을 만든다.

GetWindowsPath ( ) : string

Windows Directory의 경로를 구한다. (C:\Windows)

IsFileReadOnly ( this filename ) : bool

파일이 읽기 전용인지 검사

IsValidPath ( this path ) : bool

제대로 된 경로명인가 확인한다.

MakeVersion ( int major, int minor, int release, int build ) : string

지정된 버전 요소 값으로 버전을 나타내는 문자열을 만든다.

MoveDirectory ( this srcPath, string destPath ) : void

원본 디렉토리를 대상 디렉토리로 이동시킨다.

MoveFile ( this srcFile, string destFile, bool overwrite = false ) : void

파일 이동

ParsePath ( string path, string &root, string &dirName, string &fullFileName, string &extension ) : void

파일 경로를 분석해서 root (drive), directory, file, extension 정보를 구한다. Path.GetPathRoot() 참조

ParseVersion ( string version, int &major, int &minor, int &release, int &build ) : void

파일 버전 정보를 분해하여 각 구분별로 숫자로 나타낸다. (major.minor.release.build)

파싱이 불가능할 때에는 모든 값들이 0이 된다.

ReadTextTask ( string filepath, Encoding encoding = null ) : Task

비동기 방식으로 파일의 전체 내용을 읽어 문자열로 반환합니다.

RenameFile ( this srcFileName, string destFileName ) : void

파일명 변경, MoveFile 와 같음

Save ( string filepath, Stream stream, bool overwrite ) : void

stream을 읽어, filepath의 파일에 저장합니다. 해당 파일이 존재하면 겹쳐 쓰거나 추가를 할 수 있습니다. 파일이 없으면 새로 생성합니다.

Save ( string filepath, byte bytes, bool overwrite ) : void

바이트 배열을 지정한 파일에 저장합니다.

Save ( string filepath, string text, bool overwrite = true, Encoding enc = null ) : void

지정된 파일에 문자열을 지정된 인코딩 방식으로 저장합니다. 해당 파일이 존재하면 겹쳐 쓰거나 추가를 할 수 있습니다. 파일이 없으면 새로 생성합니다.

SaveTask ( string filepath, string text, Encoding encoding = null, bool overwrite = false ) : System.Threading.Tasks.Task

비동기 방식으로 text를 파일(filepath)에 저장합니다. 완료되었는지는 Task.IsCompleted 를 확인하세요. 대기 시에는 ((IAsyncResult)task).AsyncWaitHandle.WaitOne() 을 사용하세요.

ToByteArray ( string filepath ) : byte[]

파일을 읽어서 Byte Array로 반환한다.

ToStream ( string filepath, Encoding enc = null ) : Stream

파일 내용을 읽어서 메모리 스트림으로 변환합니다.

ToString ( string filepath, Encoding enc = null ) : string

파일 내용을 지정된 인코딩 방식으로 문자열로 변환합니다.

Private Methods

Method Description
MakeVersion ( ) : string

지정된 버전 요소 값으로 버전을 나타내는 문자열을 만든다.

Method Details

Base64Encode() public static method

파일 내용을 읽어 Base64 형식의 문자열로 변환합니다.
Http Protocol에서는 이진 Data는 전송할 수 없으므로, Base64 Encoding 방식을 기본으로 사용한다.
public static Base64Encode ( string filepath ) : string
filepath string 읽을 파일 경로
return string

Base64Encode() public static method

파일 내용을 읽어 Base64 형식의 문자열로 변환합니다.
Http Protocol에서는 이진 Data는 전송할 수 없으므로, Base64 Encoding 방식을 기본으로 사용한다.
public static Base64Encode ( this filepath, char &outArray ) : void
filepath this 읽을 파일 경로
outArray char Base64로 인코딩된 파일 내용
return void

ChangeFileAttributesToWritable() public static method

File 속성을 쓰기 가능하도록 한다.
지정한 파일을 찾을 수 없을 경우
public static ChangeFileAttributesToWritable ( this filename ) : void
filename this 속성을 설정할 파일의 전체경로
return void

CompareVersion() public static method

두 버전을 비교한다.
public static CompareVersion ( string version1, string version2 ) : int
version1 string
version2 string
return int

CopyDirectory() public static method

디렉토리 전체를 복사한다.
대상경로가 존재하지 않을 시에는 새로 만들어 사용한다.
원본 경로가 없을 시, 대상 경로의 부모 경로가 없을 시
public static CopyDirectory ( this srcPath, string destPath, bool overwrite = false ) : void
srcPath this 원본 경로
destPath string 대상 경로
overwrite bool 겹쳐쓰기 옵션
return void

CopyFile() public static method

파일 복사
public static CopyFile ( this srcFile, string destFile, bool overwrite = false ) : void
srcFile this
destFile string
overwrite bool
return void

CreateDirectory() public static method

지정한 Directory가 존재하지 않는다면 새로 생성한다.
public static CreateDirectory ( this path ) : void
path this 전체 경로
return void

CreateEmptyFile() public static method

길이가 0인 파일을 만든다.
public static CreateEmptyFile ( this filePath ) : void
filePath this 빈 파일의 전체 경로
return void

DeleteDirectory() public static method

지정된 Directory를 삭제한다. 해당 Directory에 속한 Sub Directory와 파일도 삭제 가능하다.
public static DeleteDirectory ( this path, bool recursive = true ) : void
path this 삭제할 디렉토리 경로
recursive bool 하위 디렉토리나 파일을 삭제할지 여부
return void

DeleteFile() public static method

파일 삭제
public static DeleteFile ( this filename, bool fireException = true ) : void
filename this 삭제할 파일명
fireException bool 에러발생시 throw 할 것인지 여부
return void

DirectoryExists() public static method

해당 디렉토리가 존재하는지 확인한다.
public static DirectoryExists ( this path ) : bool
path this 검사할 경로
return bool

ExtractFileExt() public static method

경로 문자열에서 파일의 Extension 문자열만 추출한다.
public static ExtractFileExt ( this path ) : string
path this
return string

ExtractFileName() public static method

경로 문자열에서 파일 이름에 해당하는 문자열만 추출한다.
public static ExtractFileName ( this path ) : string
path this
return string

ExtractFilePath() public static method

경로 문자열에서 Directory 명만 추출해 낸다.
public static ExtractFilePath ( this path ) : string
path this 경로명
return string

FileExists() public static method

파일이 존재 하는지 검사하다.
public static FileExists ( this filename ) : bool
filename this 검사할 파일의 전체 경로
return bool

FindNewFileName() public static method

파일을 겹쳐쓰기를 방지하기위해 같은 이름의 파일이 있으면 새로운 파일 이름을 반환한다.
해당 파일을 찾고, 그 파일이 없으면 해당 파일명을 반환하고, 중복되는 파일명이 있으면 "FileName[1].ext" 와 같이 뒤에 인덱스를 붙여서 만든다.
public static FindNewFileName ( this filename ) : string
filename this 원하는 파일명
return string

GetBufferedFileStream() public static method

파일 스트림을 데코레이션한 버퍼 스트림을 생성한다.
public static GetBufferedFileStream ( string filename, FileOpenMode openMode ) : BufferedStream
filename string 파일 경로 명
openMode FileOpenMode 열기 모드
return BufferedStream

GetCurrentPath() public static method

Application 현재 폴더 (Path)를 구한다.
public static GetCurrentPath ( ) : string
return string

GetDirectories() public static method

해당 폴더를 기준으로 하위 폴더의 Path를 문자열 배열로 반환한다.
public static GetDirectories ( string path ) : string[]
path string 경로
return string[]

GetDirectories() public static method

해당 폴더를 기준으로 검색 패턴과 일치하는 폴더를 검색한다.
public static GetDirectories ( string path, string searchPattern ) : string[]
path string
searchPattern string 검색할 패턴
return string[]

GetDirectorySize() public static method

지정된 경로의 크기 (서브 디렉토리와 파일의 크기를 합산) 을 구한다.
public static GetDirectorySize ( this path, bool withSubDirectory ) : long
path this 크기를 구하고자 하는 폴더의 경로
withSubDirectory bool 서브디렉토리 포함 여부
return long

GetFileCreateTime() public static method

파일의 생성 시간을 구한다.
public static GetFileCreateTime ( this filename ) : DateTime
filename this 검사할 파일의 전체 경로
return DateTime

GetFileLastWriteTime() public static method

파일에 마지막 Access한 시간
public static GetFileLastWriteTime ( this filename ) : DateTime
filename this 파일의 전체 경로
return DateTime

GetFileSize() public static method

해당 파일의 크기를 구한다.
public static GetFileSize ( this filename ) : long
filename this 검사할 파일의 전체 경로
return long

GetFileStream() public static method

파일 스트림 System.IO.FileStream을 생성해 준다.
파일이 존재하지 않을 때
public static GetFileStream ( string filename, FileOpenMode openMode ) : FileStream
filename string 대상 파일 경로
openMode FileOpenMode 열기 모드
return FileStream

GetFileSystemInfo() public static method

지정한 경로의 파일시스템를 반환합니다.
public static GetFileSystemInfo ( this path ) : FileSystemInfo
path this
return FileSystemInfo

GetFileVersion() public static method

지정된 파일의 Version 정보를 반환한다.
public static GetFileVersion ( this filename ) : string
filename this 검색할 파일의 전체경로
return string

GetFileVersionInfo() public static method

파일의 버전 정보를 구한다.
public static GetFileVersionInfo ( this filename ) : FileVersionInfo
filename this 버전 정보를 검색할 파일의 전체경로 및 이름
return FileVersionInfo

GetFiles() public static method

지정된 폴더에 있는 모든 파일의 이름을 배열로 반환한다.
public static GetFiles ( string path ) : string[]
path string 검색할 폴더
return string[]

GetFiles() public static method

지정된 폴더에 있는 파일중에 검색 패턴과 일치하는 파일의 이름을 배열로 반환한다.
public static GetFiles ( string path, string searchPattern ) : string[]
path string 경로
searchPattern string 검색 패턴
return string[]

GetNewFileName() public static method

파일을 겹쳐쓰기를 방지하기위해 지정된 파일명이 있다면, IE 처럼 파일명을 새로 생성한다.
해당 파일을 찾고, 그 파일이 없으면 해당 파일명을 반환하고, 중복되는 파일명이 있으면 "FileName[1].ext" 와 같이 뒤에 인덱스를 붙여서 만든다.
public static GetNewFileName ( this filename ) : string
filename this 원하는 파일명
return string

GetPhysicalPath() public static method

가상경로를 절대 경로로 계산한다.
public static GetPhysicalPath ( this virtualPath ) : string
virtualPath this
return string

GetProgramFilesPath() public static method

Windows Program Files 경로를 구한다. (C:\Program Files)
public static GetProgramFilesPath ( ) : string
return string

GetProgramsPath() public static method

Programs 폴더의 경로를 구한다. (C:\Documents and Settings\Administrator)
public static GetProgramsPath ( ) : string
return string

GetSpecialFolderPath() public static method

Shell의 특정 폴더를 찾는다.
시스템 특수 폴더는 공용 정보가 들어 있는 Program Files, Programs, System 또는 Startup 등과 같은 폴더입니다. 특수 폴더는 Windows를 설치할 때 기본적으로 시스템에서 설정하거나 사용자가 명시적으로 설정합니다.
public static GetSpecialFolderPath ( this folder ) : string
folder this Environment.SpecialFolder
return string

GetSystemPath() public static method

Windows System Directory의 경로를 구한다. (C:\Windows\System32)
public static GetSystemPath ( ) : string
return string

GetTempFileName() public static method

고유한 임시 파일 이름을 반환하고, 디스크에 해당 이름으로 크기가 0 바이트인 파일을 만듭니다.
public static GetTempFileName ( ) : string
return string

GetTempFileName() public static method

지정한 접두사로 고유한 임시 파일을 만들고, 디스크에 해당 이름으로 크기가 0 바이트인 파일을 만듭니다.
public static GetTempFileName ( this prefix ) : string
prefix this 파일명에 쓰일 접두사
return string

GetTempPath() public static method

시스템의 Temporary Directory를 반환한다. (C:\Documents and Settings\Administrator\Local Settings\Temp)
public static GetTempPath ( ) : string
return string

GetValidFileName() public static method

지정된 파일 경로에 금칙 문자를 주어진 대체 문자열로 변경하여, 유효한 경로 문자열을 만든다.
public static GetValidFileName ( this filename, string invalidReplacement = null, string spaceReplacement = null ) : string
filename this 변경할 파일명
invalidReplacement string 금칙문자를 대체할 문자열
spaceReplacement string 공백을 대체할 문자열 (null이면 공백은 그대로 둔다)
return string

GetValidPath() public static method

지정된 파일 경로에 금칙 문자를 주어진 대체 문자열로 변경하여, 유효한 경로 문자열을 만든다.
public static GetValidPath ( this path, string invalidReplacement = null, string spaceReplacement = null ) : string
path this 변경할 경로
invalidReplacement string 금칙문자를 대체할 문자열
spaceReplacement string 공백을 대체할 문자열 (null이면 공백은 그대로 둔다)
return string

GetWindowsPath() public static method

Windows Directory의 경로를 구한다. (C:\Windows)
public static GetWindowsPath ( ) : string
return string

IsFileReadOnly() public static method

파일이 읽기 전용인지 검사
지정한 파일이 없는 경우
public static IsFileReadOnly ( this filename ) : bool
filename this 검사할 파일의 전체 경로
return bool

IsValidPath() public static method

제대로 된 경로명인가 확인한다.
public static IsValidPath ( this path ) : bool
path this Path 문자열
return bool

MakeVersion() public static method

지정된 버전 요소 값으로 버전을 나타내는 문자열을 만든다.
public static MakeVersion ( int major, int minor, int release, int build ) : string
major int
minor int
release int
build int
return string

MoveDirectory() public static method

원본 디렉토리를 대상 디렉토리로 이동시킨다.
public static MoveDirectory ( this srcPath, string destPath ) : void
srcPath this 이동할 파일 또는 경로
destPath string 새위치
return void

MoveFile() public static method

파일 이동
public static MoveFile ( this srcFile, string destFile, bool overwrite = false ) : void
srcFile this
destFile string
overwrite bool
return void

ParsePath() public static method

파일 경로를 분석해서 root (drive), directory, file, extension 정보를 구한다. Path.GetPathRoot() 참조
public static ParsePath ( string path, string &root, string &dirName, string &fullFileName, string &extension ) : void
path string 분석할 파일 경로
root string "C:\" 같은 문자열이거나 빈 문자열
dirName string 디렉토리 정보 혹은 빈 문자열
fullFileName string 전체 파일이름 (extension 포함) 혹은 빈 문자열
extension string 파일 Extension 혹은 빈 문자열
return void

ParseVersion() public static method

파일 버전 정보를 분해하여 각 구분별로 숫자로 나타낸다. (major.minor.release.build)
파싱이 불가능할 때에는 모든 값들이 0이 된다.
public static ParseVersion ( string version, int &major, int &minor, int &release, int &build ) : void
version string 버전 정보
major int
minor int
release int
build int
return void

ReadTextTask() public static method

비동기 방식으로 파일의 전체 내용을 읽어 문자열로 반환합니다.
public static ReadTextTask ( string filepath, Encoding encoding = null ) : Task
filepath string 읽을 파일의 전체 경로
encoding System.Text.Encoding 인코딩 방식
return Task

RenameFile() public static method

파일명 변경, MoveFile 와 같음
public static RenameFile ( this srcFileName, string destFileName ) : void
srcFileName this 원본 파일 경로
destFileName string 대상 파일 경로
return void

Save() public static method

stream을 읽어, filepath의 파일에 저장합니다. 해당 파일이 존재하면 겹쳐 쓰거나 추가를 할 수 있습니다. 파일이 없으면 새로 생성합니다.
public static Save ( string filepath, Stream stream, bool overwrite ) : void
filepath string 대상 파일 경로
stream Stream 저장할 내용
overwrite bool 겹쳐쓰기 여부
return void

Save() public static method

바이트 배열을 지정한 파일에 저장합니다.
public static Save ( string filepath, byte bytes, bool overwrite ) : void
filepath string 파일 이름
bytes byte 저장할 바이트 배열
overwrite bool 겹쳐쓰기 옵션
return void

Save() public static method

지정된 파일에 문자열을 지정된 인코딩 방식으로 저장합니다. 해당 파일이 존재하면 겹쳐 쓰거나 추가를 할 수 있습니다. 파일이 없으면 새로 생성합니다.
public static Save ( string filepath, string text, bool overwrite = true, Encoding enc = null ) : void
filepath string 대상 파일 경로
text string 저장할 문자열
overwrite bool 덮어 쓰기 여부
enc System.Text.Encoding 인코딩
return void

SaveTask() public static method

비동기 방식으로 text를 파일(filepath)에 저장합니다. 완료되었는지는 Task.IsCompleted 를 확인하세요. 대기 시에는 ((IAsyncResult)task).AsyncWaitHandle.WaitOne() 을 사용하세요.
public static SaveTask ( string filepath, string text, Encoding encoding = null, bool overwrite = false ) : System.Threading.Tasks.Task
filepath string 저장할 파일의 전체경로
text string 저장할 파일 내용
encoding System.Text.Encoding 파일 내용의 인코딩 방식
overwrite bool 겹쳐쓰기 여부
return System.Threading.Tasks.Task

ToByteArray() public static method

파일을 읽어서 Byte Array로 반환한다.
public static ToByteArray ( string filepath ) : byte[]
filepath string 읽을 파일명
return byte[]

ToStream() public static method

파일 내용을 읽어서 메모리 스트림으로 변환합니다.
public static ToStream ( string filepath, Encoding enc = null ) : Stream
filepath string 읽을 파일 전체 경로
enc System.Text.Encoding 인코딩 형식
return Stream

ToString() public static method

파일 내용을 지정된 인코딩 방식으로 문자열로 변환합니다.
public static ToString ( string filepath, Encoding enc = null ) : string
filepath string 읽을 파일 전체 경로
enc System.Text.Encoding 인코딩 형식
return string