Advertisement

09.04.2008 at 09:38AM PDT, ID: 23703312
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

How does FileIOPermissions work in conjunction with IIS?  What level is responsible for allowing file output/writing for web applications (i.e. IIS or Integrated Windows Authentication ...)

Asked by John500 in Programming for ASP.NET, Microsoft Visual C#.Net, WebApplications

Greetings:

I have plenty of .Net applications that do not require any sort of FileIOPermissions to write out a log file.  I'm new to Web development and I'm finding the same rule is not true when trying to write out a log file for debugging purposes.

Please look at the code snippet I use for non Web applications.  If I try to call this code from my web application I get the following error:

System.UnauthorizedAccessException was unhandled by user code
  Message="Access to the path 'C:\\ApplicationLog.txt' is denied."
  Source="mscorlib"
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
       at System.IO.StreamWriter..ctor(String path, Boolean append)
       at WriteToFile.FileWriter.WriteToFile(String FileDest, String StrOutput) in C:\Projects\WriteToFile\WriteToFile.cs:line 25


Do I need to incorportate FileIOPermissions to get this to work or do I need to modify IIS permissions, Windows permisssions, drive permissions???  I tried adding the 'write' permission to the site directory but I don't think this is not the answer if I want to write to the 'C' drive.

Where is this error coming from?

Thanks!



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
using System;
using System.IO;
 
namespace WriteToFile
{
    public class FileWriter
    {
        // Set this to false to stop writing to file
        private static bool _WriteToFile = true;
 
        public void WriteToFile(string FileDest, string StrOutput)
        {
             if (_WriteToFile)
            {
 
                // create a writer and open the file
                TextWriter tw = new StreamWriter(FileDest, true);
 
                // write a line of text to the file
                tw.WriteLine(StrOutput);
 
                // close the stream
                tw.Close();
            }
        }
    }
}
[+][-]09.04.2008 at 11:14AM PDT, ID: 22390731

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, Microsoft Visual C#.Net, WebApplications
Sign Up Now!
Solution Provided By: Snarf0001
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.04.2008 at 11:52AM PDT, ID: 22391234

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 11:55AM PDT, ID: 22391270

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2008 at 12:14PM PDT, ID: 22402633

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628