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

The Archive Base Latest Questions

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

I’m working on some code that deals with parsing files (mainly XML, but there

  • 0

I’m working on some code that deals with parsing files (mainly XML, but there are some custom file types in there, too). I’ve got a few try-catches around the parsing code, on the off chance that something goes wrong when loading or accessing the files, and these exceptions are thrown back up to the calling object/methods.

Here’s an example:

/* main.cs */
public void LoadSomeFile (string _fullPathToFile)
{
    //create an instance of my fileLoader object
    //which is just a wrapper for the in-built
    //c# and .net methods for loading a file
    FileLoader myFileLoader = new FileLoader();

    try
    {
        //pass the fileLoader the location the file
        //to be loaded
        myfileLoader.LoadAFile(_directoryAndFileName);
    }
    catch (ParsingException parseEx)
    {
        //code to create or append to debug log file
    }

    //once the file has been loaded and parsed,
    //or if it fails, close the fileLoader
    myFileLoader.Close();
}

/* ParsingException class */
public class ParsingException : System.Exception
{
    public ParsingException()
    {
    }

    public ParsingException(string message, Exception innerException)
    {
    }

    public ParsingException(string message)
        : base(message)
    {
    }


/* in FileLoader.cs */
public void LoadAFile(string _fullPathToFile)
{
    try
    {
        /* load the file from disk */
    }
    catch (FileLoadException fileLoadEx)
    {
        throw new ParsingException("Could not load file.\nDetails: "
            + fileLoadEx.Message);
    }
    catch (FileNotFoundexception fileNotFoundEx)
    {
        throw new ParsingException("Could not find file.\nDetails: "
            + fileNotFoundEx.Message);
    }
    catch (NullReferenceException nullRefEx)
    {
        throw new ParsingException("Could not load data from file.\nDetails: "
            + nullRefEx.Message);
    }
}

I’m looking to output the parsing exceptions (and any other exceptions thrown for that matter) to a log file (the filename and format don’t matter for now, but I’m thinking of a simple text file with the name debug.txt). However, since this piece of software might be loaded onto different versions of Windows (or even different environments through Mono and similar tools/VM), I’m concerned about where I can place this debug file.

I’m building on Windows 7 Professional with UAC turned off, but if this software is loaded onto a machine with UAC turned on (either on XP, Vista or 7) I will be severely limited in my choice of possible output directories of this debug file.

Are there any specific directories that my software will definitely be able to output to, regardless of OS version and UAC settings? I was thinking that the software’s startup path should be ok (Program Files\My Project\ or Program Files (x86)\My Project\ for example ), but will there be a circumstances when this is inaccessible? (Aside from if the startup directory is made Read Only, of course) Or are there any directories that might prove better for this sort of thing? I’m hoping to find a directory that the user can navigate to easily.

  • 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:17:01+00:00Added an answer on June 1, 2026 at 4:17 am

    With UAC on Program Files is not on.

    Look at Environment.SpecialFolders. LocalApplicationData is a reasonable choice

    Standard trick is to Create a folder for you company under it, then one under that for your app, and then put your files in there.

    Known location and UAC won’t affect it.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.