Menu

[r37]: / trunk / src / Source / Replace / Program.cs  Maximize  Restore  History

Download this file

73 lines (64 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Replace
{
class Program
{
static void Main(string[] args)
{
try
{
var dir = new FileInfo(args[0]); //new DirectoryInfo(System.Environment.CurrentDirectory);
int id = 0;
string name;
string newDir = "replaced";
string[] replaceTags = {"EAID", "EAPK"};
var f= dir;
//foreach (FileInfo f in dir.GetFiles())
{
if (f.Extension == ".xml" || f.Extension == ".uml")
{
id = 0;
// dir.CreateSubdirectory(newDir);
name = Path.Combine(f.Directory.FullName,"replaced"+f.Name);//, Path.Combine(Path.Combine(f.DirectoryName, newDir), f.Name);
StreamReader r = f.OpenText();
string s = r.ReadToEnd();
foreach (string str in replaceTags)
{
while (s.Contains(str))
{
id++;
int start = s.IndexOf(str);
int end = s.IndexOf('"', start);
int end2 = s.IndexOf(' ', start);
if (end < end2)
{
string sub = s.Substring(start, end - start);
s = s.Replace(sub, "VDM." + id);
}
else
{
string sub = s.Substring(start, end2 - start);
s = s.Replace(sub, "VDM." + id);
}
}
}
FileStream file = new FileStream(name, FileMode.Create);
StreamWriter sw = new StreamWriter(file);
sw.Write(s);
sw.Close();
}
}
}
catch
(Exception
e)
{
Console.WriteLine(e.Message);
}
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.