2011-05-13 93 views

回答

0

嗨我認爲不能在命令行中完成,這是一種複雜的要求。

你想更詳細地解釋你的任務嗎?

這裏是C#中的代碼片段,可以幫助你。

 string filePath = @"c:\temp\test.txt"; 
     string line; 
     string NewText = string.Empty; 

     if (File.Exists(filePath)) 
     { 
      StreamReader file = null; 

      int linecounter = 0; 

      file = new StreamReader(filePath); 
      while ((line = file.ReadLine()) != null) 
      { 
       if(linecounter==1) 
       { 
        linecounter ++; 
        continue; 
       } 


       linecounter ++; 
      } 
      //then save the new text in a file or overwrite your current file 
1

是的,它可以在BAT腳本中完成。

閱讀HELP FORHELP SET,然後嘗試這個

@echo off 
setlocal enabledelayedexpansion 
set /a count=0 
for /f "tokens=*" %%a in (t.txt) do (
set /a count=count+1 
if /i !count! NEQ 2 echo %%a 
) 
相關問題