473,387 Members | 1,757 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,387 software developers and data experts.

Application path

hello,

How can I have the path of my web application from the global.asax.vb ? I
need the path because I have to create an xml file when the application
start.

thank you
Marc R.
Nov 19 '05 #1
3 1793
"Marc Robitaille" <ma*************@ars-solutions.caa> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
How can I have the path of my web application from the global.asax.vb ? I
need the path because I have to create an xml file when the application
start.


Have a look at Server.MapPath
Nov 19 '05 #2
Thank you,
It was what I was looking for

"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> a écrit dans le message de
news: %2****************@TK2MSFTNGP15.phx.gbl...
"Marc Robitaille" <ma*************@ars-solutions.caa> wrote in message
news:e%****************@TK2MSFTNGP14.phx.gbl...
How can I have the path of my web application from the global.asax.vb ? I
need the path because I have to create an xml file when the application
start.


Have a look at Server.MapPath

Nov 19 '05 #3
Here is some sample code I use for setting up a directory for my XML
file I/O. It's in C#, but it should give you a good idea of the overall
structure and function calls.

<snippet>
// Logging and Configuration constants
private const string EVT_PROGRAMNAME = "TekGuard
WebMail";
private const string DIR_PATHPUBLIC =
"TGWebMail\\Pub\\";

// Internal Constants
internal const string APP_PATHPUBLIC = "PathPublic";
internal const string SES_USERNAME = "UserName";
internal const string SES_PATHUSER = "PathUser";
protected void Application_Start(Object sender, EventArgs e)
{
// Create the application level data path object
string PathServer = Server.MapPath("~/");

// Get the full path of the public directory
// m_PublicPath = PathServer + DIR_PATHPUBLIC; // Root of
virtual web
m_PublicPath = Directory.GetDirectoryRoot(PathServer) +
DIR_PATHPUBLIC;

// Do I have directory storage permission, etc?
try
{
if (!Directory.Exists(m_PublicPath))
Directory.CreateDirectory(m_PublicPath);

// Create the application level data path object; Store the
path for page use
Application.Add(APP_PATHPUBLIC, PathPublic);
}
catch(Exception ex)
{
// m_LogTools.WriteWinAppEvent ("Error setting bootstrap
initialization settings (see log file for details), " + ex.Message,
EventLogEntryType.Error);
Response.Write (EVT_PROGRAMNAME + ": " + ex.Message);
throw new ApplicationException(EVT_PROGRAMNAME + ": " +
ex.Message);
}
}

internal static bool
UserInit(System.Web.SessionState.HttpSessionState Session, object
UserName, object ServerName)
{
// Create the fully qualified directory path for this user
string PathUser = m_PublicPath + ServerName.ToString().ToLower()
+ "\\" + UserName.ToString().ToLower() + "\\";

// Do I have directory storage permission, etc?
try
{
if (!Directory.Exists(PathUser))
Directory.CreateDirectory(PathUser);
Session.Add(SES_PATHUSER, PathUser);
return (true);
}
catch
{
}
return (false);
}

private void Page_Load(object sender, System.EventArgs e)
{
// Load default identity data from XML
path = Session[Global.SES_PATHUSER].ToString()
...
...
...
}

</snippet>
www.VoiceInfo.com - <a href="http://www.VoiceInfo.com">
Virtual Office, Automated Phone Assistant, Web Access </a><br>

www.TekGuard.com - <a href="http://www.TekGuard.com">
Free Mail Server, Outlook PlugIn, WebMail, Source Code </a>

Nov 19 '05 #4

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

Similar topics

11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
3
by: ramonred | last post by:
Hi, I have two web apps. Lets say main and admin for the sake of simplicity. admin is a web app within main (as a subdomain). So the path for admin is http://admin.main.com within the admin...
2
by: mark | last post by:
Can't figure this one out. I appears to not be code related. After surfing my asp.net web app for a while 5 - 10 min. it fails to open any further connections to my access 2000 database. There...
1
by: Keith | last post by:
All, I have been told this is an ASP.NET issue and not an IIS issue, so I am posting this here. I have a problem with ASP.NET returning an HTTP 500 error when trying to run ASPX pages on...
2
by: Ross | last post by:
Hi I have an application using asp.net that I am running on my PC. The web form has a text box where you can enter a name for a new Photo category then click on the button. The code is...
4
by: JOHN MALONEY | last post by:
Hi Everybody, I have created a three-tiered db application in VB .NET but I can't get the deployment to work right. I have added a SetUp project to the existing application. I also selected...
6
by: Ben Finney | last post by:
Howdy all, I'm improving an existing application that's partly written using Python and the standard library. Many of the improvements I want to make can be done by using third-party free...
0
by: steve | last post by:
I am using vb.net 2005 Express Edition. Application Settings would be a very useful thing, as a global program database that persists; if only it would work! Does anyone know a hack or a...
4
by: =?Utf-8?B?VkIgSm9ubmll?= | last post by:
I am at my witless end here, please help! I have an ASP.Net aspx web page, hosted on Windows Server 2003, that receives a query string with the path to an autocad drawing file selected from a...
0
by: Steve | last post by:
Hello- Your assistance with this issue is greatly appreciated. Environment: - Load-balanced IIS 6.0 servers (Win2003) - web servers point (via UNC path) to a Microsoft File Cluster on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.