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

C#

 
AnswerRe: single instance Pin
User 665812-Sep-06 1:36
User 665812-Sep-06 1:36 
AnswerRe: single instance Pin
jillzhang12-Sep-06 2:20
jillzhang12-Sep-06 2:20 
Questioneditor Pin
sarojkumarjena12-Sep-06 1:07
sarojkumarjena12-Sep-06 1:07 
AnswerRe: editor Pin
User 665812-Sep-06 1:13
User 665812-Sep-06 1:13 
QuestionAllowPartiallyTrustedCallers not working. Pin
Brady Kelly12-Sep-06 1:02
Brady Kelly12-Sep-06 1:02 
AnswerRe: AllowPartiallyTrustedCallers not working. Pin
Brady Kelly12-Sep-06 3:17
Brady Kelly12-Sep-06 3:17 
Questionhow Remote programing for data base applicaton Pin
Behrouz Niroomand12-Sep-06 0:58
Behrouz Niroomand12-Sep-06 0:58 
Questionhow to write to a file when there is no exceptions. Pin
zxc8912-Sep-06 0:28
zxc8912-Sep-06 0:28 
Hi All,

i am using C#.net.And i am reading a file and then writing it to another file.
The code is as follows:

	StreamReader   reader = new StreamReader("Some Path");			<br />
	StreamWriter   writer = new StreamWriter( "Some Path", false );<br />
        string line;<br />
<br />
        while ( (line = reader.ReadLine()) != null )<br />
        {<br />
             if(some condition)<br />
             {<br />
               throw new ApplicationException("Unrecognised File Format");<br />
             }<br />
             .....<br />
             .....some more "if" conditions..<br />
<br />
             writer.WriteLine( "\n    {0} = {1},",  sometext, somevalue);<br />
        }<br />
        writer.Close();<br />
	reader.Close();


So now if we observe,when any exception occurs, the application prints "Unrecognised File Format" and it doesn't write anything to the file.Also the output file is created first.

Now what i require is: Output File should be created only when there are no exceptions in the reading of the file."Some text" and "some values" are set when using the while loop..So how can i create a file when there are no exceptions in reading.

Plz Help Me!! Thanx in ADVANCE..
AnswerRe: how to write to a file when there is no exceptions. Pin
User 665812-Sep-06 1:20
User 665812-Sep-06 1:20 
QuestionRegular expression to match a string in C# Pin
Suman Singh12-Sep-06 0:08
professionalSuman Singh12-Sep-06 0:08 
AnswerRe: Regular expression to match a string in C# Pin
eggsovereasy12-Sep-06 4:11
eggsovereasy12-Sep-06 4:11 
Questiontab control for web applications Pin
Mohammad Daba'an11-Sep-06 23:47
Mohammad Daba'an11-Sep-06 23:47 
QuestionAnybody can tell me why it is wrong? Pin
steed leung11-Sep-06 23:21
steed leung11-Sep-06 23:21 
Question[Message Deleted] Pin
Nafiseh Salmani11-Sep-06 22:18
Nafiseh Salmani11-Sep-06 22:18 
AnswerRe: Media player Pin
Niiiissssshhhhhuuuuu11-Sep-06 23:39
Niiiissssshhhhhuuuuu11-Sep-06 23:39 
GeneralRe: Media player Pin
Nafiseh Salmani12-Sep-06 22:45
Nafiseh Salmani12-Sep-06 22:45 
AnswerRe: Media player Pin
Hamid_RT12-Sep-06 2:58
Hamid_RT12-Sep-06 2:58 
QuestionCode Error! Pin
Shahzad.Aslam11-Sep-06 21:23
Shahzad.Aslam11-Sep-06 21:23 
Questionhighlight search text from search results as it is in google or alibaba.com. Pin
S.Bhushan11-Sep-06 21:05
S.Bhushan11-Sep-06 21:05 
Questioncustomizing shortcut keys... Pin
Rohit Dev11-Sep-06 20:38
Rohit Dev11-Sep-06 20:38 
AnswerRe: customizing shortcut keys... Pin
Amit Kumar Chikara11-Sep-06 20:53
Amit Kumar Chikara11-Sep-06 20:53 
AnswerRe: customizing shortcut keys... Pin
Stefan Troschuetz12-Sep-06 2:58
Stefan Troschuetz12-Sep-06 2:58 
QuestionHow to convert XML data to DataSet in C#.Net Pin
AR Reddy11-Sep-06 20:15
AR Reddy11-Sep-06 20:15 
AnswerRe: How to convert XML data to DataSet in C#.Net Pin
_AK_11-Sep-06 20:28
_AK_11-Sep-06 20:28 
AnswerRe: How to convert XML data to DataSet in C#.Net Pin
Tamimi - Code11-Sep-06 20:30
Tamimi - Code11-Sep-06 20:30 

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.