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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:33:24+00:00 2026-05-14T00:33:24+00:00

In a VSTO Excel addin the code: Dim XMLDoc As XElement = XElement.Load(XMLFile1.xml) generates

  • 0

In a VSTO Excel addin the code:

Dim XMLDoc As XElement = XElement.Load("XMLFile1.xml")

generates a FileNotFound error with the message (“Could not find file ‘C:\Users\doug\Documents\XMLFile1.xml’.“) It’s looking in the My Documents folder but the XML file is located in the VS Projects folder for that project.
I have set the XML file’s “Copy to Output Directory” property to “Copy always”. When I change the code to include the full path to the XML file the code works.

Also, if I include the above code in a Windows Console or other type of project it runs correctly. I’m only getting it in the Excel Addin.
The above is true for VSTO 2008/Excel 2003 and VSTO 2010/Excel 2010.

  • 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-14T00:33:25+00:00Added an answer on May 14, 2026 at 12:33 am

    When you use the relative path, the current directory (Environment.CurrentDirectory) is used to resolve that path. In the case of a VSTO Add-in this is set to the user documents folder automatically. However for a console application that value is set to the same folder as the executable and that is why you are experiencing different behaviors.

    If your file will be deployed to the same folder as your VSTO Add-in assembly you can use (AppDomain.CurrentDomain.BaseDirectory) to build the full path to the file.

    Example, in C#:

    string filename = "XMLFile1.xml";
    
    string path = Path.Combine(
        AppDomain.CurrentDomain.BaseDirectory,
        filename);
    
    XElement.Load(path);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an Excel Addin (VSTO) in .NET that connects to an Oracle
We have a VSTO application-addin (not a document-addin) for Excel, and we want to
I am currently building an Excel 2007 Add-in using VSTO (latest version + sp1)
How does Excel VSTO Work? If I create an Excel Workbook solution in Visual
I've got a Excel VSTO 2005 application I need to debug, I've tried attaching
It seems like deployment of VSTO code is very cumbersome. My use case is
I'm getting an error compiling my VSTO (Visual Studio Tools for Office) project in
This is the VBA code for an Excel template, which I'm trying to convert
I'd like to be able to call a function exposed by a VSTO addin
I am developing an Excel VSTO C# add-in. The add-in has a single command-bar

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.