473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Deploying apps with XML files

I have written a short program which reads from XML and flat text files. I
have deployed the apllication wwith the files included but the app can no
longer find the files.
In the code, I read from the XML file with:

Dataset1.ReadXML("..\\..\\Student.xml");

This ran fine during debugging as the ..\\..\\ simply bumps it up a couple
of folders to the bin folder, where it can be read. However, once deployed
it bumped the search up to my C:\ drive. I tried to create a sub-folder
under the application folder in my set up but it still couldn't find the file.

Can anyone please tell me how to deploy an application which reads from text
or XML files.
Nov 16 '05 #1
1 2719
Hi =?Utf-8?B?Y2FzaGRlc2ttYWM=?=,
In the code, I read from the XML file with:

Dataset1.ReadXML("..\\..\\Student.xml");

This ran fine during debugging as the ..\\..\\ simply bumps it up a
couple of folders to the bin folder, where it can be read. However,
once deployed it bumped the search up to my C:\ drive. I tried to
create a sub-folder under the application folder in my set up but it
still couldn't find the file.


You are reading from an relative path!
If the file is shipped with your app you should consider using the Path
of your exe as start-path...
// Assuming Student.xml is on the same dir as the exe:
Dataset1.ReadXML(System.IO.Path.Combine(App.Startu pPath, "Student.xml"));

See: How to get the .NET applications path?
http://blog.kalmbachnet.de/?postid=7
<code>
<public class App
{
[System.Runtime.InteropServices.DllImport("kernel32 .dll",
SetLastError=true)]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern uint GetModuleFileName(
[System.Runtime.InteropServices.In]
IntPtr hModule,
[System.Runtime.InteropServices.Out]
System.Text.StringBuilder lpFilename,
[System.Runtime.InteropServices.In]
[System.Runtime.InteropServices.MarshalAs(
System.Runtime.InteropServices.UnmanagedType.U4)]
int nSize
);

public static string StartupPath
{
get
{
System.Text.StringBuilder sb = new System.Text.StringBuilder
(260);
if (GetModuleFileName(System.IntPtr.Zero, sb, sb.Capacity) == 0)
throw new System.ApplicationException("Could not retrive module
file name");
return System.IO.Path.GetDirectoryName(sb.ToString());
}
}
}
</code>
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Edwinah63 | last post by:
Hi everyone, i would like to run a vb app remotely from a client machine. the app and all the necessary dll's, drivers etc are installed on a server machine. the client does not have any vb...
3
by: Andrew | last post by:
Hi all, I am still learning ASP.Net, and .Net in general. Though I feel I have much of the "basics" down, I am running into some gray areas in more advanced topics. My question is how I make...
2
by: niv | last post by:
Hello, I am not sure what I need to do before deploying my asp.net web application. I have uploaded all aspx pages.. actually the entire project folder to my web host and then I tried typing...
2
by: timsohn | last post by:
I am trying to deploy the most basic web service (Hello World) example to my website, but am having significant trouble doing so. Here is what I am doing: 1) Create a New Web Service in VS 2005...
10
by: Bryan Dickerson | last post by:
I fairly have my Web Service working the way that I want, so my next step will be to deploy it on a server. Do I just add a deployment/install project, build it and install it on the server? ...
1
by: Mark | last post by:
When you deploy .NET 2.0 web applications, you don't have to deploy pre-compiled .dll files anymore. You deploy ALL the files (.aspx, .aspx.cs, etc) and they are compiled the first time they are...
3
by: Mark Ingram | last post by:
Hi, what steps do i need to undertake before / when i deploy a c# application? Generate strong name key? Add the file to the GAC? What else?
1
by: eva100801 | last post by:
Hi All, I have few questions about deploying windows apps developed in .Net framework. These days it is all about internet apps and services, and I need to develop small windows app and deployed...
6
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
Using Visual Studio 2005, I have created 4 small DLLs that our company projects can use to access common tools included in each of the separate DLL files. Our Visual Studio 2005 applications...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.