티스토리 툴바



2009/07/03 00:23

Flexible Display - Nokia Morph Concept Phone


처음은 Nokia에서 2008년에 공개한 차세대 휴대폰 콘셉입니다. (조금 된자료죠)

접히고,, 휘고,,

")//]]>




실제 저희나라와 일본에서도 Flexible한 디스플레이 장치를 상용화시키는데 주력하고있고

현재 실현단계까지 왔다고 알고있습니다.


저런 휴대폰을 사용하는날이 멀지 않았다는것을 새삼 깨닫습니다.


중요한것은

'어떤 기술을 어떻게 사용하겠느냐'보다는

'기존의 발상을 어떻게 깨느냐'겠죠

발상이 깨지는 순간, 꿈이라고 생각했던 기술은 현실화 되는 것 같습니다.


뭔가 동영상 하나 올리고 끝내긴 아쉬워 Flexible Display 컨셉을 몇가지 올려봅니다.

")//]]>

flexible fisplay iPhone (Concept)
")//]]>

Sony's flexible display device
")//]]>

Microsoft's flexible display device
Trackback 0 Comment 0
2009/06/26 04:09

FileInfo클래스와 DirectoryInfo클래스


FileInfo 클래스와 DirectoryInfo 클래스

1. FileInfo클래스

파일 정보를 담을 수 있는 멤버들을 제공한다.

예를들어

Name이란 변수엔 파일이름이

FullName이라는 변수엔 디렉토리 Path를 포함한 파일 이름이,

Extension에는 확장자가,

CreationTime에는 파일이 생성된 날짜 등 각종 파일에 관련된 정보들이 들어간다.

 

생성자에는 파일의 FullPath가 들어간다 (당연히 디렉토리까지 포함)

FileInfo fInfo = new FileInfo("c:\\test.txt");

간단하다.

fInfo.Name에는 “test.txt”,

fInfo.FullName에는 “c:\\test.txt” 가 들어가있겠지

 

FileInfo의 모든 멤버는 다음과 같다.

Name

Description

Attributes

Gets or sets the FileAttributes of the current FileSystemInfo. (Inherited from FileSystemInfo.)

CreationTime

Gets or sets the creation time of the current FileSystemInfo object. (Inherited from FileSystemInfo.)

CreationTimeUtc

Gets or sets the creation time, in coordinated universal time (UTC), of the current FileSystemInfo object. (Inherited from FileSystemInfo.)

Directory

Gets an instance of the parent directory.

DirectoryName

Gets a string representing the directory's full path.

Exists

Gets a value indicating whether a file exists. (Overrides FileSystemInfo..::.Exists.)

Extension

Gets the string representing the extension part of the file. (Inherited from FileSystemInfo.)

FullName

Gets the full path of the directory or file. (Inherited from FileSystemInfo.)

IsReadOnly

Gets or sets a value that determines if the current file is read only.

LastAccessTime

Gets or sets the time the current file or directory was last accessed. (Inherited from FileSystemInfo.)

LastAccessTimeUtc

Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. (Inherited from FileSystemInfo.)

LastWriteTime

Gets or sets the time when the current file or directory was last written to. (Inherited from FileSystemInfo.)

LastWriteTimeUtc

Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to. (Inherited from FileSystemInfo.)

Length

Gets the size, in bytes, of the current file.

Name

Gets the name of the file. (Overrides FileSystemInfo..::.Name.)

 

아 물론 멤버변수 말고도 파일 생성/ 삭제 등을 할 수 있도록 메서드도 제공한다.

Name

Description

AppendText

Creates a StreamWriter that appends text to the file represented by this instance of the FileInfo.

CopyTo

Overloaded. Copies an existing file to a new file.

Create

Creates a file.

CreateObjRef

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)

CreateText

Creates a StreamWriter that writes a new text file.

Decrypt

Decrypts a file that was encrypted by the current account using the Encrypt method.

Delete

Permanently deletes a file. (Overrides FileSystemInfo..::.Delete()()().)

Encrypt

Encrypts a file so that only the account used to encrypt the file can decrypt it.

Equals

Determines whether the specified Object is equal to the current Object. (Inherited from Object.)

Finalize

Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)

GetAccessControl

Overloaded. Gets a FileSecurity object that encapsulates the access control list (ACL) entries for the file described by the current FileInfo object.

GetHashCode

Serves as a hash function for a particular type. (Inherited from Object.)

GetLifetimeService

Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)

GetObjectData

Sets the SerializationInfo object with the file name and additional exception information. (Inherited from FileSystemInfo.)

GetType

Gets the Type of the current instance. (Inherited from Object.)

InitializeLifetimeService

Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)

MemberwiseClone

Overloaded.

MoveTo

Moves a specified file to a new location, providing the option to specify a new file name.

Open

Overloaded. Opens a file with various read/write and sharing privileges.

OpenRead

Creates a read-only FileStream.

OpenText

Creates a StreamReader with UTF8 encoding that reads from an existing text file.

OpenWrite

Creates a write-only FileStream.

Refresh

Refreshes the state of the object. (Inherited from FileSystemInfo.)

Replace

Overloaded. Replaces the contents of a specified file with the file described by the current FileInfo object, deleting the original file, and creating a backup of the replaced file.

SetAccessControl

Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileInfo object.

ToString

Returns the path as a string. (Overrides Object..::.ToString()()().)

 

 

2. DirectoryInfo클래스

FileInfo에 파일과 관련된 정보가 담겨있다면 DirectoryInfo클래스에는 Directory에 관한 정보가 들어있을 것이다. FileInfo클래스와 마찬가지로 디렉토리 생성/삭제등을 할 수 있는 메소드를 제공한다.

파일과 다른점은 디렉토리인만큼 하위 파일목록과 하위 디렉토리 목록을 불러오는 메소드를 제공한다는 점이다.

리턴타입은 각각 FileInfo배열과 DirectoryInfo배열이다.

즉 다음과 같이 사용할 수 있다.

 

// C: 루트 디렉토리 정보를 가져옴

DirectoryInfo dInfo = new DirectoryInfo("c:\\");

 

// 하위 FileInfo(파일정보) 배열을 받아옴

FileInfo[] fInfoSub = dInfo.GetFiles();

 

// 하위 DirectoryInfo(디렉토리정보) 배열을 받아옴

DirectoryInfo[] dInfoSub = dInfo.GetDirectories();

 

DirectoryInfo에서 제공하는 멤버는 다음과 같다.

Name

Description

Attributes

Gets or sets the FileAttributes of the current FileSystemInfo. (Inherited from FileSystemInfo.)

CreationTime

Gets or sets the creation time of the current FileSystemInfo object. (Inherited from FileSystemInfo.)

CreationTimeUtc

Gets or sets the creation time, in coordinated universal time (UTC), of the current FileSystemInfo object. (Inherited from FileSystemInfo.)

Exists

Gets a value indicating whether the directory exists. (Overrides FileSystemInfo..::.Exists.)

Extension

Gets the string representing the extension part of the file. (Inherited from FileSystemInfo.)

FullName

Gets the full path of the directory or file. (Inherited from FileSystemInfo.)

LastAccessTime

Gets or sets the time the current file or directory was last accessed. (Inherited from FileSystemInfo.)

LastAccessTimeUtc

Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. (Inherited from FileSystemInfo.)

LastWriteTime

Gets or sets the time when the current file or directory was last written to. (Inherited from FileSystemInfo.)

LastWriteTimeUtc

Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to. (Inherited from FileSystemInfo.)

Name

Gets the name of this DirectoryInfo instance. (Overrides FileSystemInfo..::.Name.)

Parent

Gets the parent directory of a specified subdirectory.

Root

Gets the root portion of a path.

 

그리고 메소드는 다음과 같다.

Name

Description

Create

Overloaded. Creates a directory.

CreateObjRef

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)

CreateSubdirectory

Overloaded. Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the DirectoryInfo class.

Delete

Overloaded. Deletes a DirectoryInfo and its contents from a path.

Equals

Determines whether the specified Object is equal to the current Object. (Inherited from Object.)

Finalize

Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)

GetAccessControl

Overloaded. Gets the access control list (ACL) entries for the current directory.

GetDirectories

Overloaded. Returns the subdirectories of the current directory.

GetFiles

Overloaded. Returns a file list from the current directory.

GetFileSystemInfos

Overloaded. Retrieves an array of strongly typed FileSystemInfo objects representing files and subdirectories of the current directory.

GetHashCode

Serves as a hash function for a particular type. (Inherited from Object.)

GetLifetimeService

Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)

GetObjectData

Sets the SerializationInfo object with the file name and additional exception information. (Inherited from FileSystemInfo.)

GetType

Gets the Type of the current instance. (Inherited from Object.)

InitializeLifetimeService

Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)

MemberwiseClone

Overloaded.

MoveTo

Moves a DirectoryInfo instance and its contents to a new path.

Refresh

Refreshes the state of the object. (Inherited from FileSystemInfo.)

SetAccessControl

Applies access control list (ACL) entries described by a DirectorySecurity object to the directory described by the current DirectoryInfo object.

ToString

Returns the original path that was passed by the user. (Overrides Object..::.ToString()()().)

 

각각의 사용법과 내용은 참고하면 되겠다.

Trackback 0 Comment 0
2009/06/26 03:53

파일 입출력


파일 입출력

파일은 FileStream이란 매개체 클래스를 통해 접근하여 읽고, 쓸 수 있다.

일반적으로 byte[]배열을 이용해 읽기/쓰기를 수행하며 사용법은 다음과 같다

 

FileStream fs = new FileStream("파일이름", FileMode.OpenOrCreate);

물론 생성자에 들어갈 수 있는 건 저것뿐만은 아니다. FileStream생성자는 15가지로 오버로딩 되어있다. 저렇게 사용할 경우 파일을 열되 없으면 생성하라라는 뜻이 되겠다.

 

오버로딩된 생성자는 다음과 같다. 위에서 사용한건 3번째거군

Name

Description

FileStream(IntPtr, FileAccess)

Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission.

FileStream(SafeFileHandle, FileAccess)

Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission.

FileStream(String, FileMode)

Initializes a new instance of the FileStream class with the specified path and creation mode.

FileStream(IntPtr, FileAccess, Boolean)

Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission and FileStream instance ownership.

FileStream(SafeFileHandle, FileAccess, Int32)

Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, and buffer size.

FileStream(String, FileMode, FileAccess)

Initializes a new instance of the FileStream class with the specified path, creation mode, and read/write permission.

FileStream(IntPtr, FileAccess, Boolean, Int32)

Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, FileStream instance ownership, and buffer size.

FileStream(SafeFileHandle, FileAccess, Int32, Boolean)

Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, buffer size, and synchronous or asynchronous state.

FileStream(String, FileMode, FileAccess, FileShare)

Initializes a new instance of the FileStream class with the specified path, creation mode, read/write permission, and sharing permission.

FileStream(IntPtr, FileAccess, Boolean, Int32, Boolean)

Obsolete. Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, FileStream instance ownership, buffer size, and synchronous or asynchronous state.

FileStream(String, FileMode, FileAccess, FileShare, Int32)

Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, and buffer size.

FileStream(String, FileMode, FileAccess, FileShare, Int32, Boolean)

Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, buffer size, and synchronous or asynchronous state.

FileStream(String, FileMode, FileAccess, FileShare, Int32, FileOptions)

Initializes a new instance of the FileStream class with the specified path, creation mode, read/write and sharing permission, the access other FileStreams can have to the same file, the buffer size, and additional file options.

FileStream(String, FileMode, FileSystemRights, FileShare, Int32, FileOptions)

Initializes a new instance of the FileStream class with the specified path, creation mode, access rights and sharing permission, the buffer size, and additional file options.

FileStream(String, FileMode, FileSystemRights, FileShare, Int32, FileOptions, FileSecurity)

Initializes a new instance of the FileStream class with the specified path, creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security.

 

어쨌든 파일을 열면 사용을 해야지!

 

1. 파일 읽기/쓰기 (byte[] 이용)

FileStream클래스에는 데이터를 byte로 읽고 쓸 수 있도록 메소드를 제공한다.

byte배열에 원하는 인덱스만큼 읽어오고 싶다면

Read()메소르를, 한바이트만 읽고 싶다면 ReadByte() 메소드를 사용하면된다.

Read

Reads a block of bytes from the stream and writes the data in a given buffer. (Overrides Stream..::.Read(array<Byte>[]()[], Int32, Int32).)

ReadByte

Reads a byte from the file and advances the read position one byte. (Overrides Stream..::.ReadByte()()().)

 

byte, byte[]로 쓰기 위한 함수 역시 Read와 마찬가지로 Write(), WirteByte()라는 함수가 존재한다.

Write

Writes a block of bytes to this stream using data from a buffer. (Overrides Stream..::.Write(array<Byte>[]()[], Int32, Int32).)

WriteByte

Writes a byte to the current position in the file stream. (Overrides Stream..::.WriteByte(Byte).)

이 밖에도 읽고 쓰기위한 여러가지 메소드들이 있으니 찾아보시길~!

 

2. 파일 읽기 쓰기 (string 이용)

우리가 많이 사용하는 건 byte가 아니라 string일 것이다. C#에서는 string이 쉽고 간편하기 때문에 많이들 사용한다. 때문에 string을 이용해 파일을 읽고 쓸 수 있도록 해주는 클래스가 존재한다.

StreamReaderStreamWriter라는 클래스이다.

(이건 파일을 읽고 쓸때만 쓰는 것은 아니다. Stream형태(MemoryStream, NetworkStream)의 바이너리 데이터를 마치 string처럼 사용할 수 있게 해주는 클래스라고 생각하면 된다.

 

생성자는 다음과 같다.

FileStream fs = new FileStream("파일이름", FileMode.OpenOrCreate);

StreamReader sr = new StreamReader(fs);

 

FileStream fs = new FileStream("파일이름", FileMode.OpenOrCreate);

StreamWriter sw = new StreamWriter(fs);

아 물론 생성자로 Stream객체 외에 여러가지가 들어갈 수 있다. StreamReader StreamWriter역시 여러가지로 오버로딩 되어있다.

 

StreamWrite의 생성자 오버로드 리스트

Name

Description

StreamWriter(Stream)

Initializes a new instance of the StreamWriter class for the specified stream, using UTF-8 encoding and the default buffer size.

StreamWriter(String)

Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the default encoding and buffer size.

StreamWriter(Stream, Encoding)

Initializes a new instance of the StreamWriter class for the specified stream, using the specified encoding and the default buffer size.

StreamWriter(String, Boolean)

Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the default encoding and buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.

StreamWriter(Stream, Encoding, Int32)

Initializes a new instance of the StreamWriter class for the specified stream, using the specified encoding and buffer size.

StreamWriter(String, Boolean, Encoding)

Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the specified encoding and default buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.

StreamWriter(String, Boolean, Encoding, Int32)

Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the specified encoding and buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.

 

StreamReader의 생성자 오버로드 리스트

Name

Description

StreamReader(Stream)

Initializes a new instance of the StreamReader class for the specified stream.

StreamReader(String)

Initializes a new instance of the StreamReader class for the specified file name.

StreamReader(Stream, Boolean)

Initializes a new instance of the StreamReader class for the specified stream, with the specified byte order mark detection option.

StreamReader(Stream, Encoding)

Initializes a new instance of the StreamReader class for the specified stream, with the specified character encoding.

StreamReader(String, Boolean)

Initializes a new instance of the StreamReader class for the specified file name, with the specified byte order mark detection option.

StreamReader(String, Encoding)

Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding.

StreamReader(Stream, Encoding, Boolean)

Initializes a new instance of the StreamReader class for the specified stream, with the specified character encoding and byte order mark detection option.

StreamReader(String, Encoding, Boolean)

Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding and byte order mark detection option.

StreamReader(Stream, Encoding, Boolean, Int32)

Initializes a new instance of the StreamReader class for the specified stream, with the specified character encoding, byte order mark detection option, and buffer size.

StreamReader(String, Encoding, Boolean, Int32)

Initializes a new instance of the StreamReader class for the specified file name, with the specified character encoding, byte order mark detection option, and buffer size.

이 역시 필요로 할 때 알아서 보기 바라며

 

우선 StremReader를 사용하여 string형식으로 읽어올 때 사용하는 메소드들은 다음과 같다.

Read

Overloaded. Reads the next character or next set of characters from the input stream.

ReadBlock

Reads a maximum of count characters from the current stream, and writes the data to buffer, beginning at index. (Inherited from TextReader.)

ReadLine

Reads a line of characters from the current stream and returns the data as a string. (Overrides TextReader..::.ReadLine()()().)

ReadToEnd

Reads the stream from the current position to the end of the stream. (Overrides TextReader..::.ReadToEnd()()().)

각각 1바이트 읽기, 특정 인덱스부터 인덱스까지 읽기, 한줄읽기, 끝까지 읽기가 되겠다.

( : string str = sr.ReadLine(); )

 

StreamWriter를 사용하여 string형식으로 파일을 쓸 때 사용하는 메소드들은 다음과 같다.

Write

Overloaded. Writes the given data type to a text stream.

WriteLine

Overloaded. Writes some data as specified by the overloaded parameters, followed by a line terminator.

Write : 문자 쓰기

WriteLine : 문자 쓰고 개행

 

이 밖에도 여러가지 메소드들을 제공하니 알아서 보길 바란다.

 

 

 

Trackback 0 Comment 0