Rich Text Box [modified]
-
Dear All, Am having Nearly 470 Text files. I want to do a text replacement in all these files. There are 60-80 replacements in each page. here is sample contents of one of the file
[](javascript:popUp\('../images/Backpack/158-62.jpg'\)) [](javascript:popUp\('../images/Backpack/194-62.jpg'\))
[](javascript:popUp\('../images/Backpack/106-62.jpg'\))
[Here for value XXX-XX it must be replaced with the .JPG file name which comes below. I have Created a Desktop Application in C# to do this. its getting converted but the alignment changes happens for files. Am doing it this way 1) Am Opening Text Fileprivate const string FILE_TAG = "[FILE]"; private const string FILENAME_TAG = "[NAME]"; private const string FILE_FILTER = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; private bool m_bIncludeRelativePath = false; private bool m_bRecurseSubDirs = false; private string m_sFilePath = string.Empty; private string m_sSourcePath = string.Empty; private string m_sInputTemplate = string.Empty; string sPingPath = string.Empty; public TEXT_REPLACE() { InitializeComponent(); } private string GetOpenFilePath() { string sFilePath = string.Empty; OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Open File"; openFile.Filter = FILE_FILTER; if (openFile.ShowDialog() == DialogResult.OK) { sFilePath = openFile.FileName; sPingPath = openFile.FileName; } return sFilePath; //return sPingPath; } private string LoadFile(string sFilePath) { FileStream file = null; StreamReader sr = null;
](javascript:popUp('../images/Backpack/106-62.jpg')) -
Dear All, Am having Nearly 470 Text files. I want to do a text replacement in all these files. There are 60-80 replacements in each page. here is sample contents of one of the file
[](javascript:popUp\('../images/Backpack/158-62.jpg'\)) [](javascript:popUp\('../images/Backpack/194-62.jpg'\))
[](javascript:popUp\('../images/Backpack/106-62.jpg'\))
[Here for value XXX-XX it must be replaced with the .JPG file name which comes below. I have Created a Desktop Application in C# to do this. its getting converted but the alignment changes happens for files. Am doing it this way 1) Am Opening Text Fileprivate const string FILE_TAG = "[FILE]"; private const string FILENAME_TAG = "[NAME]"; private const string FILE_FILTER = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; private bool m_bIncludeRelativePath = false; private bool m_bRecurseSubDirs = false; private string m_sFilePath = string.Empty; private string m_sSourcePath = string.Empty; private string m_sInputTemplate = string.Empty; string sPingPath = string.Empty; public TEXT_REPLACE() { InitializeComponent(); } private string GetOpenFilePath() { string sFilePath = string.Empty; OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Open File"; openFile.Filter = FILE_FILTER; if (openFile.ShowDialog() == DialogResult.OK) { sFilePath = openFile.FileName; sPingPath = openFile.FileName; } return sFilePath; //return sPingPath; } private string LoadFile(string sFilePath) { FileStream file = null; StreamReader sr = null;
](javascript:popUp('../images/Backpack/106-62.jpg'))I'm not sure I follow, but I'd use File.ReadAllText and File.WriteAllText ( or ReadAllLines/WriteAllLines ) to read/write the file. And if the changes are known, I'd just use string.Replace to do them.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Dear All, Am having Nearly 470 Text files. I want to do a text replacement in all these files. There are 60-80 replacements in each page. here is sample contents of one of the file
[](javascript:popUp\('../images/Backpack/158-62.jpg'\)) [](javascript:popUp\('../images/Backpack/194-62.jpg'\))
[](javascript:popUp\('../images/Backpack/106-62.jpg'\))
[Here for value XXX-XX it must be replaced with the .JPG file name which comes below. I have Created a Desktop Application in C# to do this. its getting converted but the alignment changes happens for files. Am doing it this way 1) Am Opening Text Fileprivate const string FILE_TAG = "[FILE]"; private const string FILENAME_TAG = "[NAME]"; private const string FILE_FILTER = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; private bool m_bIncludeRelativePath = false; private bool m_bRecurseSubDirs = false; private string m_sFilePath = string.Empty; private string m_sSourcePath = string.Empty; private string m_sInputTemplate = string.Empty; string sPingPath = string.Empty; public TEXT_REPLACE() { InitializeComponent(); } private string GetOpenFilePath() { string sFilePath = string.Empty; OpenFileDialog openFile = new OpenFileDialog(); openFile.Title = "Open File"; openFile.Filter = FILE_FILTER; if (openFile.ShowDialog() == DialogResult.OK) { sFilePath = openFile.FileName; sPingPath = openFile.FileName; } return sFilePath; //return sPingPath; } private string LoadFile(string sFilePath) { FileStream file = null; StreamReader sr = null;
](javascript:popUp('../images/Backpack/106-62.jpg'))IMHO it's a single line of code:
File.WriteAllText(file, File.ReadAllText(file).Replace("XXX-XX", "(the .jpg)"));
A full program:
using System.IO;
namespace BLA {
static class Program{
static void Main(string[] files)
{
foreach(string file in files)
File.WriteAllText(file, File.ReadAllText(file).Replace("XXX-XX", "(the .jpg)"));
}}}Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
-
IMHO it's a single line of code:
File.WriteAllText(file, File.ReadAllText(file).Replace("XXX-XX", "(the .jpg)"));
A full program:
using System.IO;
namespace BLA {
static class Program{
static void Main(string[] files)
{
foreach(string file in files)
File.WriteAllText(file, File.ReadAllText(file).Replace("XXX-XX", "(the .jpg)"));
}}}Greetings - Gajatko Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
It wont work since the.jpg has to be taken dynamically, its writing same file name for all XXX-XX