日期:2014-05-17 浏览次数:21074 次
string file = Server.MapPath("1.txt");
System.Text.Encoding encode=System.Text.Encoding.UTF8;//统一编码
StreamReader sr = new StreamReader(file, encode);
string txt = sr.ReadToEnd();读取
sr.Close();
StreamWriter sw = new StreamWriter(file,false,encode);
txt = "11111" + "\r\n" + txt;//添加文本
sw.Write(txt);写入
sw.Close();
------解决方案--------------------
试试:
@echo off
>c:\tmp1.tmp (
echo 111111
echo 222222
echo 333333
)
for /f "tokens=* delims=" %%i in ('dir /b c:\*.txt') do (
copy c:\tmp1.tmp+"c:\%%i" c:\tmp2.tmp /y >nul
copy c:\tmp2.tmp "c:\%%i" /y >nul
)
del c:\tmp1.tmp /f /q
del c:\tmp2.tmp /f /q
echo OK
pause>nul
------解决方案--------------------
sed -i "1s/^/111111\n222222\n/" *.txt
------解决方案--------------------
都是批处理狂人。