//生成bat脚本
FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
fs.SetLength(0);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.ASCII);
for (int i = 0; i < count_areas; i++)
{
//Console.WriteLine(array_get[i].ToString());
string[] area_and_mask = array_get[i].ToString().Split('/');
string area = area_and_mask[0];
string mask = "";
int mask_num = Convert.ToInt32(area_and_mask[1]);
UInt32 mask_0x = 0xffffffff << (32 - mask_num);
mask = (mask_0x >> 24) + "." + ((mask_0x >> 16) & 0xff) + "." + ((mask_0x >> 8) & 0xff) + "." + (mask_0x & 0xff);
string cmd = "route add " + area + " mask " + mask + " " + strGateway + " if " + manager.Idx;
sw.Write(cmd + "\n");
}
sw.Flush();
sw.Dispose();
fs.Dispose();
C#动态生成bat脚本
最新推荐文章于 2024-08-08 16:33:25 发布