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

  • Home
  • SEARCH
  • 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 563233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:38:18+00:00 2026-05-13T12:38:18+00:00

A DirectoryNotFound exception keeps happening for no apparent reason. The exception is thrown in:

  • 0

A DirectoryNotFound exception keeps happening for no apparent reason. The exception is thrown in:

public static string[] getKeywords(string filename)  
{  
    string[] keywords = XElement.Load(filename).Elements("Keyword").Attributes("name").Select(n => n.Value).ToArray();  
    return keywords;  
}

BUT it is called in this method:

public static void SyntaxHighlight(SyntaxHighlighter.SyntaxRichTextBox textbox, Language language)  
{  
    switch (language)  
    {  
        case Language.Cmake:  
            textbox.Settings.Comment = "#";  
            string[] CmakeKeywords = getKeywords("APIs\\cmake.xml");  
            textbox.Settings.Keywords.AddRange(CmakeKeywords);  
            break;  
        case Language.CSharp:  
            textbox.Settings.Comment = "//";  
            string[] CSharpKeywords = getKeywords("APIs\\cs.xml");  
            textbox.Settings.Keywords.AddRange(CSharpKeywords);  
            break;  
        case Language.HTML:  
            textbox.Settings.Comment = "<!";  
            string[] HTMLKeywords = getKeywords("APIs\\html.xml");  
            textbox.Settings.Keywords.AddRange(HTMLKeywords);  
            break;  
        case Language.Python:  
            textbox.Settings.Comment = "#";  
            string[] PythonKeywords = getKeywords("APIs\\python.xml");  
            textbox.Settings.Keywords.AddRange(PythonKeywords);  
            break;  
    }  
}

UPDATE:
I have a folder in my project called APIs. I checked the file names several times. Here is the exception: Could not find a part of the path 'C:\Users\Mohit\Documents\Visual Studio 2010\Projects\Notepad\Notepad\bin\Debug\APIs\cs.xml'. Thats the EXACT path of the file!

  • 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-13T12:38:18+00:00Added an answer on May 13, 2026 at 12:38 pm

    There’s little hope of your program ever finding that folder. When you deploy your app, there is no project folder. The best way to organize it is to add the .xml files to your project with Project + Add Existing. Select them in Solution Explorer and in the Properties window set Build action = None and Copy to Output Directory = Copy if Newer. Build. That puts the files in the same directory as your .exe.

    Find them back at runtime with System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)

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

Sidebar

Related Questions

I am new in LINQtoXML. I want to use XElement.Load() Method. but the compiler
This code is supposed to download a file using mvc3 controller public FilePathResult GetFileFromDisk(String
Why would the code below throw a io.system.directorynotfound exception? I can't recreate the problem
I'm trying to load a .xps document into a DocumentViewer object in my WPF
I am loading an xml file from my applicatin: XDocument.Load(HttpContext.Current.Server.MapPath(/) + XMLMetadata\\Actions.1.xml); In the
I am writing an app and I want to load a file based on
Consider the following code snippet private void ProcessFile(string fullPath) { XmlTextReader rdr = new
I've never had the need catch more than one exception at a time before.
I'm just starting to use the Enterprise Library Exception Handling block. It seems a
Is there any way, to auto generate the catch, for all possible exception, that

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.