DirectoryNotFoundException: app is looking in bin\x86\Debug for my xml file

Is there a way, during development, to make it so that you can have the XML 
file in the same folder in which the bin folder is found?  It seems crazy to 
me that during Debug that it is looking in the bin folder if it isn't 
putting it in that bin folder.

Line that expects it to be in the  bin\x86\Debug folder : XPathDocument doc 
= new XPathDocument(@"myfilename.xml");

During debugging, I get a DirectoryNotFoundException unless the file is in 
bin\x86\Debug

How do I do what I want?  Is there some setting I don't know about?

Thanks,

Reese 


0
7/31/2007 11:22:40 PM
dotnet.xml 7266 articles. 0 followers. Follow

6 Replies
364 Views

Similar Articles

[PageSpeed] 15

Well I found 
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=65821&SiteID=1 which 
gives the answer for VB (thanks to jkiley who posted there):

sXML = "bcodes.xml"

sXML = Replace(Replace(Application.StartupPath, "\bin\Debug", Space(0)), 
"\bin\Release", Space(0)) & "\xml\" & sXML

Kiley appears to be putting the file into an \sml\ directory. 
Application.StartupPath seems to be the VB equivalent of C#'s 
Environment.CurrentDirectory.

An alternative which I am using is to do a conditional compile:

            string xmlFilePath = @"XML\filename.xml";
#if DEBUG
            xmlFilePath = @"..\..\..\XML\filename.xml";
#endif

It is just wrong that this is the way it has to be, creating kludges for a 
VS shortcoming.  I was hoping someone would say that isn't the way it is, 
but apparently a kludge is needed.  If I am mistaken, please post the 
information I was seeking.

R




"Reece" <neweducation@yahoo.com> wrote in message 
news:4vPri.30755$2v1.24374@newssvr14.news.prodigy.net...
> Is there a way, during development, to make it so that you can have the 
> XML file in the same folder in which the bin folder is found?  It seems 
> crazy to me that during Debug that it is looking in the bin folder if it 
> isn't putting it in that bin folder.
>
> Line that expects it to be in the  bin\x86\Debug folder : XPathDocument 
> doc = new XPathDocument(@"myfilename.xml");
>
> During debugging, I get a DirectoryNotFoundException unless the file is in 
> bin\x86\Debug
>
> How do I do what I want?  Is there some setting I don't know about?
>
> Thanks,
>
> Reese
> 


0
8/1/2007 6:14:11 PM
Reece wrote:
> Well I found 
> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=65821&SiteID=1 which 
> gives the answer for VB (thanks to jkiley who posted there):
> 
> sXML = "bcodes.xml"
> 
> sXML = Replace(Replace(Application.StartupPath, "\bin\Debug", Space(0)), 
> "\bin\Release", Space(0)) & "\xml\" & sXML
> 
> Kiley appears to be putting the file into an \sml\ directory. 
> Application.StartupPath seems to be the VB equivalent of C#'s 
> Environment.CurrentDirectory.
> 
> An alternative which I am using is to do a conditional compile:
> 
>             string xmlFilePath = @"XML\filename.xml";
> #if DEBUG
>             xmlFilePath = @"..\..\..\XML\filename.xml";
> #endif
> 
> It is just wrong that this is the way it has to be, creating kludges for a 
> VS shortcoming.  I was hoping someone would say that isn't the way it is, 
> but apparently a kludge is needed.  If I am mistaken, please post the 
> information I was seeking.
> 
> R
> 
> 
> 
> 
> "Reece" <neweducation@yahoo.com> wrote in message 
> news:4vPri.30755$2v1.24374@newssvr14.news.prodigy.net...
>> Is there a way, during development, to make it so that you can have the 
>> XML file in the same folder in which the bin folder is found?  It seems 
>> crazy to me that during Debug that it is looking in the bin folder if it 
>> isn't putting it in that bin folder.
>>
>> Line that expects it to be in the  bin\x86\Debug folder : XPathDocument 
>> doc = new XPathDocument(@"myfilename.xml");
>>
>> During debugging, I get a DirectoryNotFoundException unless the file is in 
>> bin\x86\Debug
>>
>> How do I do what I want?  Is there some setting I don't know about?
>>
>> Thanks,
>>
>> Reese
>>
> 
> 

When this code goes live (put into production, or whatever) what will 
the current directory be that the code executes "from?" In other words, 
how will the code find this file in production?

Once that is known then ideas for pointing to the file while debugging 
will probably be easier to suggest.

-- 
-glenn-
0
gdoten (2)
8/1/2007 6:49:01 PM
>
> When this code goes live (put into production, or whatever) what will the 
> current directory be that the code executes "from?" In other words, how 
> will the code find this file in production?
>
> Once that is known then ideas for pointing to the file while debugging 
> will probably be easier to suggest.
>
> -- 
> -glenn-


Current directory would be Environment.CurrentDirectory.  The xml file would 
be located relative to that directory.  I have already listed two working 
solutions for pointing to it both during debugging and runtime.  But the 
fact that MSFT doesn't handle this transparently is seems like terrible 
design to me, and I was hoping that I was missing something.  It doesn't do 
this nonsense when it comes to Content in XNA games, it does the obvious 
thing and copies over the relevant audio and image content files to the 
appropriate bin folder so that a kludge is not necessary.

R



"G.Doten" <gdoten@gmail.com> wrote in message 
news:eqx0fyG1HHA.4476@TK2MSFTNGP06.phx.gbl...
> Reece wrote:
>> Well I found 
>> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=65821&SiteID=1 
>> which gives the answer for VB (thanks to jkiley who posted there):
>>
>> sXML = "bcodes.xml"
>>
>> sXML = Replace(Replace(Application.StartupPath, "\bin\Debug", Space(0)), 
>> "\bin\Release", Space(0)) & "\xml\" & sXML
>>
>> Kiley appears to be putting the file into an \sml\ directory. 
>> Application.StartupPath seems to be the VB equivalent of C#'s 
>> Environment.CurrentDirectory.
>>
>> An alternative which I am using is to do a conditional compile:
>>
>>             string xmlFilePath = @"XML\filename.xml";
>> #if DEBUG
>>             xmlFilePath = @"..\..\..\XML\filename.xml";
>> #endif
>>
>> It is just wrong that this is the way it has to be, creating kludges for 
>> a VS shortcoming.  I was hoping someone would say that isn't the way it 
>> is, but apparently a kludge is needed.  If I am mistaken, please post the 
>> information I was seeking.
>>
>> R
>>
>>
>>
>>
>> "Reece" <neweducation@yahoo.com> wrote in message 
>> news:4vPri.30755$2v1.24374@newssvr14.news.prodigy.net...
>>> Is there a way, during development, to make it so that you can have the 
>>> XML file in the same folder in which the bin folder is found?  It seems 
>>> crazy to me that during Debug that it is looking in the bin folder if it 
>>> isn't putting it in that bin folder.
>>>
>>> Line that expects it to be in the  bin\x86\Debug folder : XPathDocument 
>>> doc = new XPathDocument(@"myfilename.xml");
>>>
>>> During debugging, I get a DirectoryNotFoundException unless the file is 
>>> in bin\x86\Debug
>>>
>>> How do I do what I want?  Is there some setting I don't know about?
>>>
>>> Thanks,
>>>
>>> Reese
>>>
>>
>>


0
8/1/2007 7:14:46 PM
Reece wrote:
>> When this code goes live (put into production, or whatever) what will the 
>> current directory be that the code executes "from?" In other words, how 
>> will the code find this file in production?
>>
>> Once that is known then ideas for pointing to the file while debugging 
>> will probably be easier to suggest.
>>
>> -- 
>> -glenn-
> 
> 
> Current directory would be Environment.CurrentDirectory.  The xml file would 
> be located relative to that directory.  I have already listed two working 
> solutions for pointing to it both during debugging and runtime.  But the 
> fact that MSFT doesn't handle this transparently is seems like terrible 
> design to me, and I was hoping that I was missing something.  It doesn't do 
> this nonsense when it comes to Content in XNA games, it does the obvious 
> thing and copies over the relevant audio and image content files to the 
> appropriate bin folder so that a kludge is not necessary.
> 
> R
> 
> 
> 
> "G.Doten" <gdoten@gmail.com> wrote in message 
> news:eqx0fyG1HHA.4476@TK2MSFTNGP06.phx.gbl...
>> Reece wrote:
>>> Well I found 
>>> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=65821&SiteID=1 
>>> which gives the answer for VB (thanks to jkiley who posted there):
>>>
>>> sXML = "bcodes.xml"
>>>
>>> sXML = Replace(Replace(Application.StartupPath, "\bin\Debug", Space(0)), 
>>> "\bin\Release", Space(0)) & "\xml\" & sXML
>>>
>>> Kiley appears to be putting the file into an \sml\ directory. 
>>> Application.StartupPath seems to be the VB equivalent of C#'s 
>>> Environment.CurrentDirectory.
>>>
>>> An alternative which I am using is to do a conditional compile:
>>>
>>>             string xmlFilePath = @"XML\filename.xml";
>>> #if DEBUG
>>>             xmlFilePath = @"..\..\..\XML\filename.xml";
>>> #endif
>>>
>>> It is just wrong that this is the way it has to be, creating kludges for 
>>> a VS shortcoming.  I was hoping someone would say that isn't the way it 
>>> is, but apparently a kludge is needed.  If I am mistaken, please post the 
>>> information I was seeking.
>>>
>>> R
>>>
>>>
>>>
>>>
>>> "Reece" <neweducation@yahoo.com> wrote in message 
>>> news:4vPri.30755$2v1.24374@newssvr14.news.prodigy.net...
>>>> Is there a way, during development, to make it so that you can have the 
>>>> XML file in the same folder in which the bin folder is found?  It seems 
>>>> crazy to me that during Debug that it is looking in the bin folder if it 
>>>> isn't putting it in that bin folder.
>>>>
>>>> Line that expects it to be in the  bin\x86\Debug folder : XPathDocument 
>>>> doc = new XPathDocument(@"myfilename.xml");
>>>>
>>>> During debugging, I get a DirectoryNotFoundException unless the file is 
>>>> in bin\x86\Debug
>>>>
>>>> How do I do what I want?  Is there some setting I don't know about?
>>>>
>>>> Thanks,
>>>>
>>>> Reese
>>>>
>>>
> 
> 

What I've seen done (and what I do) in this case is to have a post-build 
event in Visual Studio that copies the file from wherever it lives 
during development to the directory it needs to be in when the code runs 
under the debugger.

Just FYI: If you have the test capabilities in VS, and if you create a 
unit test for your code, then you can use the DeploymentItem attribute 
(I think that's it name) on the test case's method and VS' test engine 
will copy the file for you.

-- 
-glenn-
0
gdoten (2)
8/1/2007 8:26:25 PM
Thanks, Glenn.  At this point I think I will just keep my kludge, unless as 
my app grows it becomes a problem that would make it more of a hassle than 
what you have offered here.  But thanks for the ideas, which I will keep in 
mind.

R

>
> What I've seen done (and what I do) in this case is to have a post-build 
> event in Visual Studio that copies the file from wherever it lives during 
> development to the directory it needs to be in when the code runs under 
> the debugger.
>
> Just FYI: If you have the test capabilities in VS, and if you create a 
> unit test for your code, then you can use the DeploymentItem attribute (I 
> think that's it name) on the test case's method and VS' test engine will 
> copy the file for you.
>
> -- 
> -glenn- 


0
8/1/2007 8:42:21 PM
I discovered that the answer is to view the properties of the xml file in 
question in the VS environment and select an appropriate option for the 
"Copy to output directory" property.  The default seems to be "Do not copy". 
The output directory is the appropriate bin folder.

Reece


"Reece" <neweducation@yahoo.com> wrote in message 
news:4vPri.30755$2v1.24374@newssvr14.news.prodigy.net...
> Is there a way, during development, to make it so that you can have the 
> XML file in the same folder in which the bin folder is found?  It seems 
> crazy to me that during Debug that it is looking in the bin folder if it 
> isn't putting it in that bin folder.
>
> Line that expects it to be in the  bin\x86\Debug folder : XPathDocument 
> doc = new XPathDocument(@"myfilename.xml");
>
> During debugging, I get a DirectoryNotFoundException unless the file is in 
> bin\x86\Debug
>
> How do I do what I want?  Is there some setting I don't know about?
>
> Thanks,
>
> Reece
> 


0
8/23/2007 5:03:00 PM
Reply:

Similar Artilces:

Drag a file(path) from an Access Form into another app?
I’ve read all about dragging files INTO Access forms, and dragging and dropping data between controls on Access forms. I need to do something different: MyApp has a subform with a list of files in a folder on the local HD. Currently I have buttons that opens the file using a Shell() command. The Users want to be able to drag files out of the list (on the subform in Access) and into other programs (like Notepad or Word), and have them open just like you dragged a file there out of windows explorer. I downloaded modules that “expose that Windows API” before, I’m assuming ...

Outlook2003
Hi All, When my PC crashed and went in for repair, I got a new hard drive plus motherboard, I was not to worried as I ran a back up on BT Vault system, previously. I have recovered all my files to my hard drive except outlook.pst, it shows about 48 meg in size, when I try to import it to MS outlook, I cannot see much difference and I cannot see Sent files etc. Would be glad for any tips how to recover it. Tom Buchanan Don't use import. File-> Open-> Outlook Data File... -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outloo...

What graphic file format prints best out of Excel?
I'm having trouble with my graphics printing out clearing from Excel. I've imported some logos onto a spreadsheet and it look nice on the screen but prints very fuzzy. Any suggestions? Thanks! Maybe Printer Setup............set for "best quality" Vaya con Dios, Chuck, CABGx3 "MCmomma" wrote: > I'm having trouble with my graphics printing out clearing from Excel. I've > imported some logos onto a spreadsheet and it look nice on the screen but > prints very fuzzy. Any suggestions? Thanks! ...

Receiving XML Documents
Hi, I'm setting up a service that receives a XML document, validates the document using a schema and then returns a simple result. I wanted to ask what the best way is of doing this, that is sending the xml document. So far I've come across 2 way's: 1. Create a webservice that accepts a XMLNode. 2. Use HttpWebRequest to send the document as a stream. The service would be written in .NET but the clients can be written in any programing language. Thanks, EG elguapo, Since interoperability is important in your case (your #2 requirement), it is not suggested that you send any d...

Copying data from multiple files
I am trying to create a macro that will copy the values of several different ranges from a series of identically formatted workbooks to a single new file to create a database. So far I have the following code that does what I need for a single file, but I need to have the macro recognize each new file rather than being fixed on the first file (TEST 1). TEST 1 is the active file when I start the macro. Most of this was done via the macro recorder as my knowledge of VBA is extremely limited. Sub FOB_REVIEW() ' ' Range("B2").Select Application.CutCopyMode = False ...

windows app embed java app
Hi Windows application embed IE control embed applet <--- this is the way i know that emebd a java app into a windows app, but the disadvantage is slow, because applet take a longer time to load than a normal standalone java app. Is there any way to embed a JFrame/Java standalone application(with interface) into a windows app? thanks from Peter (cmk128@hotmail.com) ...

XML reading issue....
I have some XML file like that: === <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>affiliateId</key> <string>AFL9124395098</string> ........................... === Now when I'm reading them with XmlDocument or XmlTextReader the reader try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "h...

i am looking for a template for the front page of a newspaper
i want to do a front page for a newspaper and can't find a suitable template Publisher is geared more toward newsletters than newspapers. Many templates here. http://office.microsoft.com/en-us/results.aspx?Scope=TC&Query=newspaper -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Ann" <Ann@discussions.microsoft.com> wrote in message news:D009AF69-44E9-4719-9C33-FFFDDAFADFC4@microsoft.com... >i want to do a front page for a newspaper and can't find a suitable template Try a newsstand. Look how differ...

Illegal characters in file names
In ALL previous versions of Word and Excel for the Mac, the slash character "/" was allowed in file names. And, as an arrogant Mac guy, I always delighted in the fact that DOS and Windows folks were not allowed to use the slash and other special characters in file names. (And, yes, I do know why.) But, my arrogance may have finally caught up with me. It appears that in Office X, I CANNOT use the slash in file names. And, I have 15 years worth of Word and Excel files (over 38,000 files) in which I've used the slash in dates (e.g., <<2003/12/18_file name >>). Now, the...

XL2000
I have a workbook with 5 sheet. No sheet has more than 200 rows and 20 columns of data (most are less) . There are multiple formulas in the various sheets. These are simple sumif w/nested if statements. The file size was about 201K bytes. I recently added a 6th sheet that was very similar in size and nature to the others. When I saved it, the new version jumped up to close to 5M bytes in size. The workbook has no externl links, macros, VB. It is simply $ values and formulas. One of the sheets represents master data that the others make reference too. I also check that the...

Good XML-Database?
Hello! I'm looking for a (free, if possible) XML-Database wich is usable from ..NET-Code (especially XPath-Queries and XSLT) I know eXist, but it is only accessible via WebServices or HTTP and the only working method (from .NET) is depreceated (XQuery does not work, it requires some kind of compiler?!) Or: are there any working RDF-Stores for .NET or Win32? There are the W3C-Scripts but I don't want to install even more scripting-environments. Some Java implementations look nice but they have too much features (built-in HTTP-Server, integration with some Apache-Tools) to por...

Report creation in Excel Using VB.Net App.
Hello All, We're just looking into options for creating report output for our application. We've used Crystal before and found limitations, so have taken to writing reports direclty into MS Excel, (add in DLL, and create sheet and data via direct code) and it appears to be working just fine so far. I was just curious if anyone else has taken this approach and if it's worked well for them. Thanks & all the best, Ed. ...

Send an email via MFC app?
Hi folks, I would like to send an email via my MFC app. Is this possible in MFC? Are there any classes developed for MFC which provide this functionality? Thanks in advance for any tips. Best Regards, David See http://www.codeproject.com/tools/multimail.asp There's a section titled "Sending mail using the ATL7 classes" -- Regards, Nish [VC++ MVP] http://www.voidnish.com http://blog.voidnish.com "David++" <David@discussions.microsoft.com> wrote in message news:77259322-C605-4314-ACA1-BFAC795451F3@microsoft.com... > Hi folks, > > I would like to s...

app to app thread notification
Is there any way to do app to app thread notification? I have used WM_COPYDATA before to SendMessage to another app, but now I want to send a message directly to one of the receiving app's threads. I was thinking that RegisterWindowMessage might work. For example on the receiving side: static const UINT uniqueWindowsMsg = ::RegisterWindowMessage( _T("abcdefg")); ON_REGISTERED_MESSAGE( uniqueWindowsMsg, OnUniqueWindowsMsgHandler ) And on the sending app's side same desktop: static const UINT uniqueWindowsMsg = ::RegisterWindowMessage( _T("abcdefg")); ::PostThreadMe...

Outlook 2000 slow to attach files
I am running Outlook 2000 with XP, and when I go to attach a file on the network, it is extremely slow. However, when I go to the same file through Windows Explorer, it is very quick. Does anyone know what this problem might be or how to fix it? ...

produce a truly hierarchical xml
Any help appreciated. I have two Access tables, customer and orders. I would like to create a truly hierarchical xml file form the joined tables. I need to produce: <Query1> <Customer> <Name>Bob</Name> <Order> <ID>1001</ID> </Order> <Order> <ID>1002</ID> </Order> </Customer> <Customer> <Name>Helen</Name> <Order&...

create pivot table from external csv file
I am dumping huge data to csv file, Now what I want to do is, create pivot table/chart from csv file without importing data into it. Reason behind doing this is, end user view updated report without messing with thier limited excel knowledge. Hi, So what's your question? If you're asking if it can be done, the answer is Yes. If you're asking how to do it, the question is - what version of Excel are you using? For Example in 2003 you would choose Data, Pivot Table and Pivot Chart Report, and choose External data source, Next, Get Data, choose New Data Source and cl...

the auto up/down App
How do I turn off the auto-up/down function in media trying to pick songs from my Library? On Sun, 11 Apr 2010 15:34:01 -0700, DGAZACCT <DGAZACCT@discussions.microsoft.com> wrote: > >How do I turn off the auto-up/down function in media trying to pick songs >from my Library? Hi, I'm a little confused by your problem description. Could you re-phrase it with steps needed to reproduce what problem you're having (as simple as click this, press that, drag file etc) Cheers - Neil ------------------------------------------------ Digital Media MVP : 2004...

gp should have auto-pick from bins with lowest qty on hand
GP should have a feature to automatically pick items for a sales transaction from the bin with the lowest on-hand quantity. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mi...

Lost the .pub file, what now?
Hi I have publisher 2000 and have made a web page and I accidentally deleted the .pub file! Is there any way I can convert the web files back into a .pub file so that I can edit the web pages? Thanks Ted You cannot go back... How are you uploading the web site? You should be able to download your web page from your server. If you haven't emptied your Internet temp folder lately, it will be in that folder too. Publisher will create temp files, your file may be in the Windows temp folder. Look here too: In Windows Explorer, on the address bar, type %temp% -- Mary Sauer MS MVP http:/...

Look up column name, match rows (a/cnumber) & summing up....its confusing!
Hi All, Here is what I'v been trying to do but..! I'v 2 sets of data (data1 & data2) Column name may be sane/different in each data set and same applies to acct_no.. I want to prepare a report that combine product & accounts data show accumulatd result on another sheet/file. Data 1 - upto Jan 2006 Acct. No Total Prod - A Prod - B Prod-C 1001 51 10 30 11 1002 47 15 20 12 1003 80 20 15 45 1004 64 25 16 23 Total 242 70 81 91 Data 2 - Feb 2006 Acct. No Total Prod - A Prod - B 1002 7 5 2 1004 16 10 6 1009 9 3 6 Total 32 18 14 Report required Acct upto Jan'06 Prod - ...

PST File missing
My system crashed. I had copied my "C" drive to another logical drive and when I reinstalled Windows XP all my Outlook data was, of course, not there in new Outlook. Where can I find it and how do I copy it over? Thanks. Do a file search on the logical drive you copied your c drive over to for the file Outlook.pst. Take that file and put it into the same folder on your c drive. "Werner Stern" <quincey.nyc@verizon.net> wrote in message news:OM3Qtj3mDHA.2432@TK2MSFTNGP10.phx.gbl... > My system crashed. I had copied my "C" drive to another logical dri...

Can you take a file from 2003 to 2000?
I have office 2003 at home. Can I take Excel/Word files from my office pc (office 2000), work on them at home and then go back to the office 2000 at work and bring them up? On Sat, 23 Apr 2005 19:14:01 -0700, cgc <cgc@discussions.microsoft.com> wrote: >I have office 2003 at home. Can I take Excel/Word files from my office pc >(office 2000), work on them at home and then go back to the office 2000 at >work and bring them up? Generally yes. There hasn't been any real change in the basic Excel and Word document formats between those versions. (Unlike Access.) The main ...

Getting File Version Info
I am trying to use the following command to get the version info of an specific file in Powershell: PS C:\> gc Servers.txt | foreach { [system.diagnostics.fileversioninfo]::GetVersionInfo \\$_\C$\windows\system32\drivers\storport.sys } However, I'm getting the following error: Unexpected token '\\$_\C$\windows\system32\drivers\storport.sys' in expression or statement. At line:1 char:126 + gc Servers.txt | foreach { [system.diagnostics.fileversioninfo]::GetVersionInfo \\$_\C$\windows\system32\drivers\storport.sys <<<< } + CategoryInfo ...

Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Xml.XmlAttribute'
I have the foll. code to update the value of an attribute: xmlDocument.Load("abc.xml"); XmlAttribute xmlAttrib = xmlDocument.SelectSingleNode(root/web/theme/@desc); xmlAttrib.Value = ddDes.SelectedItem.ToString(); xmlDocument.Save("abc.xml"); However, I get the foll. error: Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Xml.XmlAttribute' What code should be modified so that the error is resolved. Thanks. > XmlAttribute xmlAttrib = xmlDocument.SelectSingleNode(root/web/theme/@desc); should be XmlAttribute xmlAttrib = (XmlAttribut...