Click here to Skip to main content
15,922,574 members
Home / Discussions / C#
   

C#

 
GeneralRe: Strange Problem at writing file Pin
J4amieC30-Aug-07 5:09
J4amieC30-Aug-07 5:09 
GeneralRe: Strange Problem at writing file Pin
error140830-Aug-07 5:12
error140830-Aug-07 5:12 
GeneralRe: Strange Problem at writing file Pin
Spacix One30-Aug-07 5:14
Spacix One30-Aug-07 5:14 
GeneralRe: Strange Problem at writing file Pin
error140830-Aug-07 5:18
error140830-Aug-07 5:18 
GeneralRe: Strange Problem at writing file Pin
Spacix One30-Aug-07 5:59
Spacix One30-Aug-07 5:59 
GeneralRe: Strange Problem at writing file Pin
Luc Pattyn30-Aug-07 6:42
sitebuilderLuc Pattyn30-Aug-07 6:42 
GeneralRe: Strange Problem at writing file Pin
error140830-Aug-07 7:38
error140830-Aug-07 7:38 
Questionchatting between c# and asp.net Pin
_beginner_30-Aug-07 2:31
_beginner_30-Aug-07 2:31 
AnswerRe: chatting between c# and asp.net Pin
Colin Angus Mackay30-Aug-07 2:35
Colin Angus Mackay30-Aug-07 2:35 
GeneralRe: chatting between c# and asp.net Pin
_beginner_30-Aug-07 2:43
_beginner_30-Aug-07 2:43 
GeneralRe: chatting between c# and asp.net Pin
J4amieC30-Aug-07 3:40
J4amieC30-Aug-07 3:40 
GeneralRe: chatting between c# and asp.net Pin
_beginner_30-Aug-07 4:07
_beginner_30-Aug-07 4:07 
GeneralRe: chatting between c# and asp.net Pin
Colin Angus Mackay30-Aug-07 4:11
Colin Angus Mackay30-Aug-07 4:11 
GeneralRe: chatting between c# and asp.net Pin
_beginner_30-Aug-07 4:21
_beginner_30-Aug-07 4:21 
GeneralRe: chatting between c# and asp.net Pin
Not Active30-Aug-07 4:12
mentorNot Active30-Aug-07 4:12 
GeneralRe: chatting between c# and asp.net Pin
_beginner_30-Aug-07 4:22
_beginner_30-Aug-07 4:22 
GeneralRe: chatting between c# and asp.net Pin
Not Active30-Aug-07 4:36
mentorNot Active30-Aug-07 4:36 
GeneralRe: chatting between c# and asp.net Pin
_beginner_30-Aug-07 8:44
_beginner_30-Aug-07 8:44 
Questioncan any one tell me how to encrypt the connection stirng Pin
prasadbuddhika30-Aug-07 2:21
prasadbuddhika30-Aug-07 2:21 
AnswerRe: can any one tell me how to encrypt the connection stirng Pin
snorkie30-Aug-07 2:28
professionalsnorkie30-Aug-07 2:28 
AnswerRe: can any one tell me how to encrypt the connection stirng Pin
Not Active30-Aug-07 2:28
mentorNot Active30-Aug-07 2:28 
QuestionNeed help with an exception Pin
MicealG30-Aug-07 2:21
MicealG30-Aug-07 2:21 
AnswerRe: Need help with an exception Pin
Alaric_30-Aug-07 2:28
professionalAlaric_30-Aug-07 2:28 
GeneralRe: Need help with an exception Pin
MicealG30-Aug-07 3:54
MicealG30-Aug-07 3:54 
Questionhow to add new line Pin
Situ1430-Aug-07 1:33
Situ1430-Aug-07 1:33 
hello

when i compiling this code its appended allthe lines in one line..

I want to keep the file as it is and want to add comment where there is assemblyVersionInfo string...


String strPathToFile = "Put here the path to the .cs file";
System.IO.StreamReader sr = new System.IO.StreamReader(strPathToFile);
System.Text.StringBuilder strAllText = new System.Text.StringBuilder();
bool AlreadyCommented = false;
do
{
if(sr.Peek() == -1) break;
String line = sr.ReadLine();
if(line.IndexOf("AssemblyVersion") > -1 && line.IndexOf("//") > -1) AlreadyCommented = true;
strAllText.Append(line);
}
sr.Close();
if(AlreadyCommented) return;
System.IO.FileInfo fi = new System.IO.FileInfo(strPathToFile);
fi.CopyTo(strPathToFile + ".bak"); //backup copy of the old file
int posOfAssemblyVersion = strAllText.ToString().IndexOf("AssemblyVersion");
//Look for the closing bracket "]"
int posOfClosingBracket = strAllText.ToString().IndexOf("]", posOfAssemblyVersion);
string strComments = "//Put there the desired comments";
strAllText = strAllText.Insert(posOfClosingBracket, strComments);
System.IO.StreamWriter sw = new System.IO.StreamWriter(strPathToFile, false); //overwrites the original
sw.Write(strAllText.ToString());
sw.Close();

if you have any ans then plz reply as soon as

thanks

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.