views:

69

answers:

1

Hi experts,

I have a CPP file. I am using VB in VS2005. I have opened that file using the FileSystemObject. I am reading each and every line in that CPP file. I have to comment all the lines untill i encounter a return statement.I am using the scripting.textstream to read a line from the CPP file. But i have no idea as to how we can add a "//" comment to the beginning of every line that i read or even a multiline comment from the begining till a return statement. pls help !!

+1  A: 

You seem to be using the FileSystemObject of the Windows script runtime instead of the System.IO.File class's methods. Strange!

The static System.IO.File.ReadAllLines() will read a file (and close it) and return a string array containing all the lines. You could then iterate through the array and add a comment to each line (except if the line starts with return).

Finally, save the changed text to the file using any of the WriteAllLines() method, thus overwriting any contained text.

Adding a multiline comment at the start would be even easier, you would not need to read the lines into an array.

Cerebrus
If there are any multiline comments in the file though these will break it. You're better off prepending // to every line that comes through
Matthew Steeples