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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:18:02+00:00 2026-05-27T14:18:02+00:00

I am developing a webpart that should read an XML file. For this I

  • 0

I am developing a webpart that should read an XML file. For this I have created a class, in which the NodeValue() method should return the text inside of nodes. This does work if tested with a console application, however when I add this(reader class and custom XML file) to my SharePoint project and try to deploy it, I get the error message Web Part error: File Not Found. I tried changing the file properties so as it is added to the compiled version, but I still seem to have trouble with specifying the path to the file. Here is the reader class:

using System;
using System.Reflection;
using System.IO;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OrgChartPart.WebPartCode
{
class ReadXml
{

    public string FilePath { get; set; }

    public ReadXml()
    {
        FilePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)+"\\LAYOUTS\\config.xml";
    }

    public string NodeValue(int pos)
    {
        if (pos <= 0)
            return "invalid position!(this is not a node value)";

        XmlTextReader textReader = new XmlTextReader(FilePath);

        int counter = 0;

        while (counter != pos)
        {
            textReader.Read();
            if (textReader.NodeType.ToString() == "Text")
                counter++;
        }
        return textReader.Value;
    }
}
}

And here is a part of the web part code where I instanciate this class to read the file:

StringBuilder sb = new System.Text.StringBuilder();

.......
            string position = null, link_type = null, link_color = null, 
                node_alignment = null, node_fill = null, node_color_style = null, hyperlinks = null;

            ReadXml readXml = new ReadXml();

            sb.Append(@"
........

I don’t know if I am having trouble with identifying the path of the file, or do I need to have heighten permission to access it? Or maybe when the solution gets deployed the directory structure is changed, so I am specifying a wrong path? What do you think?
Thanks in advance

  • 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-27T14:18:03+00:00Added an answer on May 27, 2026 at 2:18 pm

    Well, I managed to solve it..somewhat..
    I added the XML file(or CSS or whatever u want) via SharePoint API(on the farm), after which I was able to access the file using the virtual path of the file(u can see the directory structure using Sharepoint Design Manager and opening your farm),

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

Sidebar

Related Questions

I am developing silverlight web part for sharepoint 2010. I have an xml file
I am developing one sharepoint webpart, in this i have 2 date time control,
When developing whether its Web or Desktop at which point should a developer switch
My current project for work involves developing a SharePoint 2007 WebPart which will be
Developing a web application that I've registered with Twitter. In this app, I might
I am developing a WebPart (it will be used in a SharePoint environment, although
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Developing a project of mine I realize I have a need for some level
I have been developing pages and web parts in SharePoint 2007/2010 for the past
We currently have a product that uses Sharepoint and a number different Web Part

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.