Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: web.config file access in another project Pin
Marco Bertschi7-Feb-14 3:56
protectorMarco Bertschi7-Feb-14 3:56 
GeneralRe: web.config file access in another project Pin
vkEE7-Feb-14 4:23
vkEE7-Feb-14 4:23 
GeneralRe: web.config file access in another project Pin
Marco Bertschi7-Feb-14 4:34
protectorMarco Bertschi7-Feb-14 4:34 
GeneralRe: web.config file access in another project Pin
vkEE7-Feb-14 4:39
vkEE7-Feb-14 4:39 
GeneralRe: web.config file access in another project Pin
Marco Bertschi7-Feb-14 4:39
protectorMarco Bertschi7-Feb-14 4:39 
QuestionHandling Multiple result sets in EF Pin
meeram395-Feb-14 4:04
professionalmeeram395-Feb-14 4:04 
AnswerRe: Handling Multiple result sets in EF Pin
Matt U.5-Feb-14 10:39
Matt U.5-Feb-14 10:39 
QuestionHow to close a TextWriter? Pin
Zhivko Kabaivanov5-Feb-14 2:53
Zhivko Kabaivanov5-Feb-14 2:53 
Hello fellow C# developers.
I am doing a little bit login system.I came to a point where I need to log my operations for every user. I made custom Log static class, because I don't need not used objects.
I have the following method in the class.
C#
public static void Logging(string logMessage, string user)
        {
            using (Writer)
            {
                Writer.Write("\r\nLog Entry : ");
                Writer.Write(
                    "{0} {1}\r\n user: {2}",
                    DateTime.Now.ToLongTimeString(),
                    DateTime.Now.ToLongDateString(),
                    user);
                Writer.WriteLine(": {0}", logMessage);
                Writer.WriteLine("-------------------------------");
            }
        }


When I use it for the first time is OK upon button click events, but when I call it again, I get an Exception. I checked it and it was "Cannot write to a closed TextWriter". So what seems to be the problem?
Isn't using opening and closing the writer, so when I open it again it would be ok?
AnswerRe: How to close a TextWriter? PinPopular
Richard Deeming5-Feb-14 3:02
mveRichard Deeming5-Feb-14 3:02 
QuestionSQL Server Database for C# connectivity Pin
Mohan Subramani5-Feb-14 1:06
Mohan Subramani5-Feb-14 1:06 
AnswerRe: SQL Server Database for C# connectivity Pin
OriginalGriff5-Feb-14 1:33
mveOriginalGriff5-Feb-14 1:33 
SuggestionRe: SQL Server Database for C# connectivity Pin
Richard Deeming5-Feb-14 2:59
mveRichard Deeming5-Feb-14 2:59 
QuestionSQL Exception was unhandled Pin
Oonagh5-Feb-14 0:32
Oonagh5-Feb-14 0:32 
AnswerRe: SQL Exception was unhandled Pin
Kornfeld Eliyahu Peter5-Feb-14 1:14
professionalKornfeld Eliyahu Peter5-Feb-14 1:14 
GeneralRe: SQL Exception was unhandled Pin
Oonagh5-Feb-14 1:18
Oonagh5-Feb-14 1:18 
AnswerRe: SQL Exception was unhandled Pin
Kornfeld Eliyahu Peter5-Feb-14 1:29
professionalKornfeld Eliyahu Peter5-Feb-14 1:29 
GeneralRe: SQL Exception was unhandled Pin
Oonagh5-Feb-14 1:30
Oonagh5-Feb-14 1:30 
AnswerRe: SQL Exception was unhandled Pin
Kornfeld Eliyahu Peter5-Feb-14 1:31
professionalKornfeld Eliyahu Peter5-Feb-14 1:31 
Questionwant to generate random number Pin
Diya Bh.4-Feb-14 23:17
Diya Bh.4-Feb-14 23:17 
AnswerRe: want to generate random number Pin
Marco Bertschi4-Feb-14 23:29
protectorMarco Bertschi4-Feb-14 23:29 
GeneralMessage Closed Pin
5-Feb-14 0:10
Diya Bh.5-Feb-14 0:10 
GeneralRe: want to generate random number Pin
Marco Bertschi5-Feb-14 0:15
protectorMarco Bertschi5-Feb-14 0:15 
GeneralRe: want to generate random number Pin
Diya Bh.5-Feb-14 0:24
Diya Bh.5-Feb-14 0:24 
AnswerRe: want to generate random number Pin
Eddy Vluggen5-Feb-14 0:30
professionalEddy Vluggen5-Feb-14 0:30 
GeneralRe: want to generate random number Pin
Diya Bh.5-Feb-14 0:37
Diya Bh.5-Feb-14 0:37 

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.