using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;namespace _oneline
{
class Program
{
static void Main(string[] args)
{
string path = @"D:\\MS_HD_08_H576i25_to_H264_960x1080p25_4.sh"; string logstring = @""; FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
StreamReader sr = new StreamReader(fs); StreamWriter sr_ = new StreamWriter(fs);
string[] _line = sr.ReadToEnd().Split('\r'); sr.Close(); for (int i = 0; i < _line.Length; i++)
{ int _i = -1;
int _h = -1;
int _w = -1; if (_line[i].ToString().IndexOf(@"-u32PID") > 0
&& _line[i].ToString().IndexOf(@"-u32BitRate") > 0
&& _line[i].ToString().IndexOf(@"-instance") > 0)
{ string[] temp = _line[i].ToString().Split(' '); for (int j = 0; j < temp.Length; j++)
{
if (temp[j].ToString() == @"-instance")
{ _i = int.Parse(temp[j + 1].ToString()); } if (temp[j].ToString() == @"-u32BitRate")
{ _w = int.Parse(temp[j + 1].ToString()); } if (_i == 9 || _i == 13 || _i == 8 || _i == 12 || _i == 10 || _i == 14)
{ if (_w == 4000000)
{ _line[i] = _line[i].Replace(@"-u32BitRate " + _w.ToString(), @"u32BitRate 400000"); }
}
}
} logstring = logstring + _line[i].ToString(); } StreamWriter logfile = new StreamWriter(path);
logfile.WriteLine(logstring);
logfile.Close();
Console.ReadLine();
} }
}
C#
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;namespace _oneline
{
class Program
{
static void Main(string[] args)
{
string path = @"D:\\MS_HD_08_H576i25_to_H264_960x1080p25_4.sh"; string logstring = @""; FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
StreamReader sr = new StreamReader(fs); StreamWriter sr_ = new StreamWriter(fs);
string[] _line = sr.ReadToEnd().Split('\r'); sr.Close(); for (int i = 0; i < _line.Length; i++)
{ int _i = -1;
int _h = -1;
int _w = -1; if (_line[i].ToString().IndexOf(@"-u32PID") > 0
&& _line[i].ToString().IndexOf(@"-u32BitRate") > 0
&& _line[i].ToString().IndexOf(@"-instance") > 0)
{ string[] temp = _line[i].ToString().Split(' '); for (int j = 0; j < temp.Length; j++)
{
if (temp[j].ToString() == @"-instance")
{ _i = int.Parse(temp[j + 1].ToString()); } if (temp[j].ToString() == @"-u32BitRate")
{ _w = int.Parse(temp[j + 1].ToString()); } if (_i == 9 || _i == 13 || _i == 8 || _i == 12 || _i == 10 || _i == 14)
{ if (_w == 4000000)
{ _line[i] = _line[i].Replace(@"-u32BitRate " + _w.ToString(), @"u32BitRate 400000"); }
}
}
} logstring = logstring + _line[i].ToString(); } StreamWriter logfile = new StreamWriter(path);
logfile.WriteLine(logstring);
logfile.Close();
Console.ReadLine();
} }
}
C#
解决方案 »
- 求思路,大家可以给点意见
- 错别字改正系统或者软件
- 关于listview为新对象添加图标的问题(不急)
- 菜鸟求助,很简单的东懂
- 求读写CSV文件,能够处理各种特殊字符的标准代码,不用OleDb
- dll动态库的有效期是怎么控制的?》
- 如何访问远程ftp目录中的一个文件啊?
- winform中dataGridView右键菜单的问题!急急急急!!!
- $$$$$$$$$$win98开机出现"disk I/O error" 用启动盘进dos,a:>c:回车后,找不到c区,D驱能找得到。但fdisk可以看见c区信息,请问这是为什
- 这本《Microsoft Visual C#.NET程序设计》有没有看过?
- IList<T>如何转成List<T>
- 在C#中怎样同时插入两张表,sql语句怎么写?
然后遍历所有文件
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;namespace _oneline
{
class Program
{
static void Main(string[] args)
{
string folderpath = @"D:\M17\"; DirectoryInfo TheFolder = new DirectoryInfo(folderpath);
// aaa = conn_nxd.BeginTransaction();
foreach (FileInfo NextFile in TheFolder.GetFiles())
{
if (NextFile.Extension.ToUpper() != @".SH")
{ continue;
}
string path = folderpath + NextFile.Name;
string logstring = @"";
int i = 0; FileStream fs = new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
StreamReader sr = new StreamReader(fs); StreamWriter sr_ = new StreamWriter(fs);
string[] _line = sr.ReadToEnd().Split('\r'); sr.Close(); if (_line[i].Contains("./xcode.configGenericVideoEnc.pl"))
{
for (i = 0; i < _line.Length; i++)
{ int _i = -1;
int _h = -1;
int _w = -1; if (_line[i].ToString().IndexOf(@"-u32PID") > 0
&& _line[i].ToString().IndexOf(@"-u32BitRate") > 0
&& _line[i].ToString().IndexOf(@"-instance") > 0)
{ string[] temp = _line[i].ToString().Split(' '); for (int j = 0; j < temp.Length; j++)
{
if (temp[j].ToString() == @"-instance")
{ _i = int.Parse(temp[j + 1].ToString()); } if (temp[j].ToString() == @"-u32BitRate")
{ _w = int.Parse(temp[j + 1].ToString()); } if (_i == 9 || _i == 13 || _i == 8 || _i == 12 || _i == 10 || _i == 14)
{ if (_w == 4000000)
{ _line[i] = _line[i].Replace(@"-u32BitRate " + _w.ToString(), @"u32BitRate 400000"); }
}
} }
} logstring = logstring + _line[i].ToString(); } StreamWriter logfile = new StreamWriter(folderpath + NextFile.Name);
logfile.WriteLine(logstring);
logfile.Close();
Console.ReadLine();
} } }
}我这样改的 可是不行报错呢