2012-02-27 2 views
3

C#에서 응용 프로그램을 만들고 있습니다. 여기에 특정 파일의 바이트 수를 찾고 싶습니다. 여기에 코드를 사용하고 있습니다.파일에서 바이트 수를 찾는 방법은 무엇입니까?

using(FileStream fs=new FileStream(filename,FileMode.Open,FileAccess.Read)) 
{ 
    //Here i want to find the number of Bytes. 
    //Some more code. 
} 

제발 도와주세요. 미리 감사드립니다.

답변

6

FileStream.Length 속성을 사용합니다.

스트림의 길이 (바이트)를 가져옵니다.

9

당신은 (AN Int64로)의 length 바이트를 얻기 위해 FileInfo 클래스를 사용할 수 있습니다 :

new FileInfo(filename).Length; 
관련 문제