---
title: "Error while loading string to xml document in windows c#"  
description: "Error while loading string to xml document in windows c#"  
author: "Anonymous User"  
published: 2013-05-10  
updated: 2013-05-10  
canonical: https://www.mindstick.com/forum/855/error-while-loading-string-to-xml-document-in-windows-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Error while loading string to xml document in windows c#

Hi Expert!\
I have an [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) where it reads the [xml data](https://www.mindstick.com/forum/149/problem-in-showing-the-xml-data-in-table-form-on-browser), makes some changes and saves it into a [word document](https://www.mindstick.com/forum/1869/read-from-word-document-line-by-line). When i run the app 1st time the base URI is "C:\[Documents](https://www.mindstick.com/articles/156931/the-main-types-of-business-documents)\
\[Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) 2010\[Projects](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects)\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug". But when i run the second time without restarting the app the base URI \
changes to last saved [location](https://www.mindstick.com/blog/11636/relocating-business-or-office-to-another-location) ans i get an error saying the [xml file](https://www.mindstick.com/forum/360/how-to-read-xml-file-in-php) not found.Below is the part of code. Where am I gng wrong\
string xmlSource = string.Empty;\
if (string.IsNullOrEmpty(xmlSource)) xmlSource = "Dictionary.xml"; XmlDocument doc = new XmlDocument(); doc.Load(xmlSource); [FileStream](https://www.mindstick.com/interview/34113/what-are-the-differences-between-filestream-flush-flushasync-and-dispose) usrFs = null; try { usrFs = new FileStream(xmlSource, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); }\
catch (IOException ex) { MessageBox.Show(ex.Message); } try { doc.Load(usrFs); } catch ([Exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) ex) { MessageBox.Show(ex.Message); } Thanks in advance! \

## Replies

### Reply by AVADHESH PATEL

Hi!\
Try as following \
Use full path rather than relative path.\
xmlSource = System.AppDomain.CurrentDomain.BaseDirectory + "\\Dictionary.xml";\
I hope it helpful for you!


---

Original Source: https://www.mindstick.com/forum/855/error-while-loading-string-to-xml-document-in-windows-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
