2009-11-11 7 views
1

텍스트 파일이 있습니다. 파일의 내용을 역순으로 읽어야합니다 (EOF에서). Nant 스크립트를 사용하여 어떻게 달성 할 수 있는지 알려주십시오.파일을 역순으로 읽는 중

감사합니다, Priya.R

+0

읽은 후 (줄 단위 또는 문자 단위로) 읽은 후에는 무엇을 할 것입니까? – Don

+0

파일에 이름 목록이 있으므로 끝에있는 이름을 읽음으로써 일부 작업이 필요합니다. –

답변

1

는이 같이 당신은 NAnt 스크립트 내에서 C#으로 그것을 작성할 수

<target name="read"> 
    <script language="C#" prefix="myprefix" > 
     <code> 
      <![CDATA[ 
       [Function("reverse-lines")] 
       public static string ReverseLines(string s) 
       { 
        string[] lines = s.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); 
        string result = ""; 
        foreach (string line in lines) 
        { 
         result = line + "\r\n" + result; 
        } 

        return result; 
       } 

      ]]> 
     </code> 
    </script> 

    <loadfile file="myfile.txt" property="contents" /> 
    <echo message="File contents in correct order:" /> 
    <echo message="${contents}" /> 
    <echo message="File contents in reverse order:" /> 
    <echo message="${myprefix::reverse-lines(contents)}" /> 
</target> 
0

당신은 파일의 정렬 된 복사본을 생성하기 위해 Windows 프로그램 sort /R를 사용할 수 있습니다.

관련 문제