Hi,
I've a directory whereby an external program A will generate random filenames in it. They're text files which are used as input to another program B. I'll like to create a C# program C which is scheduled periodically to edit the files and remove special characters from the files.
How should I go about it
Ideas anyone TIA !

Get rid of special characters
Sean D Wright
In the previous case, here are the steps:
First of all, add a Timer component to your program. Add appropriate interval, and enable it. Create Tick event handler, it should perform (at least) the following:
1) Create System.IO.DirectoryInfo
ex: DirectoryInfo dir = new DirectoryInfo(Enviroment.CurrentDirectory);
2) Get the filenames inside your directory
FileInfo[] files = dir.GetFiles();
3) Now work the files in foreach loop, one file at the time
4) Open the file using TextReader or such
TextReader reader = new SreamReader(theFile.FullName); //theFile is a FileInfo object in foreach loop
5) read contents of the file inside StringBuilder object (for enhanced performance), whole file to end or line at a time in a loop, its your call
6) then use Replace method of the StringBuilder to replace the characters of your choice with empty strings, thus remove them: strBuild.Replace("#", "");
7) now construct the new file from replaced strings, and write it to the file using TextWriter.
Hope this helps---
Richard Hough
Hi,
I think ruhan's post will give enough information how to internally handle files and remove special characters from file...
Here i will like to add few points...
Each of your file has goes through a step of sequence that should be maintained...
Mean program B should not access file until its processed by program C and proram C should accessed only newly created files...
You can handle this by many ways but what i would like to do simply is...
I will create two folders for example
1)NewFiles
2)ModifiedFiles
Now program A will create files and put them NewFiles Direcotry
Program C will will Load files from NewFile directory and put them in ModifiedFiles directory
Now program B will only looking files from directory ModifiedFiles and get input from them and then if these files are not needed in any case then delete then or put them in some back or processed file folder.
Hope this help.
NandaRengasamy