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
>>>>
>>>
>
>