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 6910319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:47:56+00:00 2026-05-27T08:47:56+00:00

I have a recent problem . I can upload file in my intetpub/wwwrooot/folder But

  • 0

I have a recent problem . I can upload file in my intetpub/wwwrooot/folder

But I can’t write a log file in this same folder …

I have all the permissions for the network service. Everything is on my server.

DirectoryInfo di = new DirectoryInfo(~/);

// Get a reference to each file in that directory.
FileInfo[] fiArr = di.GetFiles();


string strLogText = di;

// Create a writer and open the file:
StreamWriter log;

if (!System.IO.File.Exists("C:\\inetpub\\wwwroot\\logfile.txt"))
{
    log = new StreamWriter("C:\\inetpub\\wwwroot\\logfile.txt");
}
else
{
    log = System.IO.File.AppendText("C:\\inetpub\\wwwroot\\logfile.txt");
}

// Write to the file:
log.WriteLine(DateTime.Now);
log.WriteLine(strLogText);
log.WriteLine();

// Close the stream:
log.Close();

The error is the access is denied !

It works locally , but on my server it doesnt. On the folder Inetpub , I just need to allow writting for Network service ? That is strange because I can upload file and writting is already enable

  • 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-27T08:47:57+00:00Added an answer on May 27, 2026 at 8:47 am

    Emged in case of exceptions your code does not close the streams on the log file and this is surely not good.

    You should use a using statement around the streams so in any case streams are closed and disposed also in case of exceptions.

    As Chris has suggested I would absolutely opt for a logging Framework and I would also avoid writing in that wwwroot folder.

    ELMAH or NLog or Log4Net are good and easy alternatives far better than any custom logging lie you are doing right now and the big advantage of these technologies/libraries is that you can change the behaviour at runtime simply by editing the configuration file, no need to rebuild or redeploy anything…

    my favourite is actually Log4Net, check these ones for a simple example on how to use it:

    http://logging.apache.org/log4net/release/manual/configuration.html

    Log4Net in App object?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I am newer to python and have been researching this problem but I
I don't have this problem on my local development environment, but I just deployed
This seems like it can be a recent problem since there are new versions
I have a weird problem, I successful installed celery, but I can't import its
This is a recent problem... MySQL was working and a couple of days ago
I have this very basic problem, >>> from django.core import serializers >>> serializers.serialize(json, {'a':1})
I have installed psyco in one machine with no problem, but i'm getting an
I have encountered a weird problem: as far as I know, cache can be
I have the following problem to solve and I can't seem to be able
I have a problem similar to the first problem in this question , which

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.