Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1056577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:44:02+00:00 2026-05-16T17:44:02+00:00

This is main program.cs LogError.WriteError(Application started: + DateTime.Now + Environment.NewLine); try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);

  • 0

This is main program.cs

LogError.WriteError("Application started: " + DateTime.Now + Environment.NewLine);
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new CrawlerApp());
            }
            catch (Exception e)
            {
                LogError.WriteError(e);
            }
            LogError.WriteError("Application closed: " + DateTime.Now + Environment.NewLine);

and this is LogError class

public static class LogError
    {
        public static void WriteError(Exception e)
        {
            WriteError("Message: " + e.Message + Environment.NewLine + "Stack trace: " + e.StackTrace);
        }

        public static void WriteError(string error)
        {
            try
            {
                StreamWriter sw = File.AppendText("log.txt");
                sw.WriteLine(DateTime.Now + Environment.NewLine);
                sw.WriteLine(error + Environment.NewLine);
                sw.WriteLine(Environment.NewLine);
                sw.Close();
            }
            catch (Exception)
            {
                //
            }
        }
    }

When i publish application and run it log.txt file is never created. If i run application from bin/debug folder then works. Why when i publish app logging not working. I am using win 2003 OS.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:44:03+00:00Added an answer on May 16, 2026 at 5:44 pm

    File.AppendText only works if the file already exists: http://msdn.microsoft.com/en-us/library/system.io.file.appendtext.aspx. This link also has this sample code:

    string path = @"c:\temp\MyTest.txt";
        // This text is added only once to the file.
        if (!File.Exists(path)) 
        {
            // Create a file to write to.
            using (StreamWriter sw = File.CreateText(path)) 
            {
                sw.WriteLine("Hello");
                sw.WriteLine("And");
                sw.WriteLine("Welcome");
            }   
        }
    
        // This text is always added, making the file longer over time
        // if it is not deleted.
        using (StreamWriter sw = File.AppendText(path)) 
        {
            sw.WriteLine("This");
            sw.WriteLine("is Extra");
            sw.WriteLine("Text");
        }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing C++ win32 console app. This application contains a main program
I use the Frama-C tool to generate the dependence graph of this program(main.c). #include<stdio.h>
My program is like this ( main.c ): #include <stdlib.h> #include <stdio.h> void main(){
Consider this program int main() { float f = 11.22; double d = 44.55;
Code first: '''this is main structure of my program''' from twisted.web import http from
This is my program: int main(int argc, char *argv[]){ if(argc != 2){ printf(Uso: ./server
This program returns: package main import ( flag fmt ) func main() { num_agents
In this c program a=8; main() { printf(%d, a); } variable a has been
First look at this code: class Program { static void Main(string[] args) { var
In this C program #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.