how to solve this problem?
hi there,
i submitted last week problem till there. see first: http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/ff62549f-a153-4fa4-ab6c-726ed15d4d37
it works string (the sign removed pipe not comma now) not line fed text file. see code used follows:
string tempfile = path.gettempfilename();
using (var sr = new streamreader (@"c:\oldfile.txt"))
{
using (var sw = new streamwriter (tempfile))
{
string line;
while (line = sr.readline() != null)
{
string pattern = "(?<=(.*?\\|){4})(.*?\\|)";
regex pipetoremove = new regex(pattern);
string match = pipetoremove.match(line).value;
string switchwith = match.replace("|", " ");
line = line.replace(match, switchwith);
sw.writeline(line);
}
file.delete(oldfile.txt);
file.move(tempfile, oldfile.txt);
now when run it gives error msg "process can't access file c:\oldfile.txt because being used bby process". not sure where, somewhere code not right. plz advise. appreciate time.
allan
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment