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 have code that worked in the VSTO version of an Excel Addin Microsoft.Office.Tools.Excel.ListObject
I am converting a MFC C++ COM Addin to a VSTO Excel Addin in
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'm looking through some VSTO excel code and there seems to be a major
I have an Excel VSTO AddIn that I moved up to Excel 2007/VS2010 last
So I want to capture some key-commands in our Docuement-level Excel VSTO addin. I
I've developed an Excel 2003 addin in C#, using VSTO and VS 2008. The
I have a shared COM AddIn (not VSTO) for excel 2003, now I want
Is there a way to deploy a vsto Excel 2010 AddIn to a list

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.