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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:33:08+00:00 2026-06-01T04:33:08+00:00

I want my user to be able to hit the submit button and have

  • 0

I want my user to be able to hit the submit button and have a string write into a css file. When I hit the submit button, I am getting the error message:

Access to the path ‘C:/…..’ is denied

This happens when running the site from localhost and on my hosting (123reg)

protected void btnSubmit(object sender, EventArgs e) 
{ 
   using (StreamWriter writer = new StreamWriter("B00101168.css")) 
   { 
      writer.Write("Word "); 
      writer.WriteLine("word 2"); 
   } 
}
  • 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-06-01T04:33:10+00:00Added an answer on June 1, 2026 at 4:33 am

    The first problem is, you can’t write to a file without setting permissions on the folder. See this link for details. Essentially, you must give the Internet Guest Account permission to write to the folder.

    But, the bigger problem is, you probably shouldn’t be trying to dynamically write a CSS file anyway. At least, not the way you are trying to do it. Can you explain why you are trying to dynamically change a CSS file on your server? If you can explain what you are trying to accomplish, I might have some suggestions on how to do it that work better than what you are trying to do.

    UPDATE: You’re using WebForms, and you’re trying to dynamically generate CSS. So here’s one way to do that.

    Use a generic page handler — a file that ends in .ashx. You dynamically create the CSS however you’re doing it now, but instead of writing it to a file, you output it directly to the browser. Here is some (untested!) code:

    In the DynamicStyles.ashx file, there is basically nothing to add from what it automatically generates.

    In the DynamicStyles.ashx.cs file:

    public void ProcessRequest( HttpContext context )
    {
        StringBuilder css = new StringBuilder();
        // Use the StringBuilder to generate the CSS 
        // however you are currently doing it.
    
        context.Response.ContentType = "text/css";
        context.Response.Write( css.ToString() );
    }
    

    Then, in your code that needs the CSS file, include it just like you would any other CSS:

    <link rel="stylesheet" type="text/css" href="/path/to/DynamicStyles.ashx">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the user to be able to enter a name for a file
I have a MovieClip that I want the user to be able to drag
I have a dictionary of strings that i want the user to be able
I have a file field in my form. I want the user to be
I want the user to be able to have some data already in the
I have a purchase page and I don't want the user to be able
I want the user to be able to make some preferences like colors, prefered
I want the user to be able to see my application in the menu
I want the user to be able to select an option, which would change
I want the user to be able to choose from a dropdown Combobox listing

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.