473,569 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VS2005 - how to specify location of a text file in dev and production?

dgk
I have a few text files that I read in at run time into label
controls; they're stored in a Text folder in the app. At run time I
try to read them in by using "~/text/thefile.txt" but it doesn't work
in the editor or when published. I've tried a few appgetpath type
things and can't get one to work.

Any help greatly appreciated.
Mar 18 '07 #1
5 988
The "~" syntax is inderstood by aspx pages only. Try just
MapPath("text/thefile.txt").

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"dgk" <No*****@MailsA nonymous.comwro te in message
news:rp******** *************** *********@4ax.c om...
>I have a few text files that I read in at run time into label
controls; they're stored in a Text folder in the app. At run time I
try to read them in by using "~/text/thefile.txt" but it doesn't work
in the editor or when published. I've tried a few appgetpath type
things and can't get one to work.

Any help greatly appreciated.

Mar 18 '07 #2
dgk
On Sun, 18 Mar 2007 10:26:38 +0200, "Eliyahu Goldin"
<RE************ **************@ mMvVpPsS.orgwro te:
>The "~" syntax is inderstood by aspx pages only. Try just
MapPath("tex t/thefile.txt").
Yes, that works. Thanks.
Mar 18 '07 #3
I use this function:
I find it easier to wrap this up in a function for maintenance , debugging
and consistency issues.
Its probably a little overkill, but I'm come to trust it, for than random
MapPaths all over the place.


public static string FindPhysicalRoo tDirectory(Page p)
{
string rootDir;
rootDir = p.Server.MapPat h("~/");
return rootDir;
}


Public Shared Function FindPhysicalRoo tDirectory(ByVa l p As Page) As
String

Dim rootDir As String

rootDir = p.Server.MapPat h("~/")

Return rootDir

End Function
I have another counter part:

public static string FindVirtualRoot Directory(Page p)
{
return "~/";
}

It seems to work.
Remember , in 2.0 remember to test against IIS deployment and the casino web
server deployment. (the local non iis port-number deployment)

If you wait to test IIS until deployment, you may be surprised it doesn't
work.

"dgk" <No*****@MailsA nonymous.comwro te in message
news:rp******** *************** *********@4ax.c om...
I have a few text files that I read in at run time into label
controls; they're stored in a Text folder in the app. At run time I
try to read them in by using "~/text/thefile.txt" but it doesn't work
in the editor or when published. I've tried a few appgetpath type
things and can't get one to work.

Any help greatly appreciated.

Mar 19 '07 #4
dgk
On Mon, 19 Mar 2007 10:30:47 -0400, "sloan" <sl***@ipass.ne twrote:
Public Shared Function FindPhysicalRoo tDirectory(ByVa l p As Page) As
String

Dim rootDir As String

rootDir = p.Server.MapPat h("~/")

Return rootDir

End Function
Thanks, I select this one being a VB guy. But is there some reason not
to just do:

Dim rootDir as String = p.Server.MapPat h("~/")

or even just

Return p.Server.MapPat h("~/")
I'm not sure what any of them get you over just throwing MapPath("~/")
into the code?
Mar 20 '07 #5

Did you test against

IIS vs Casino deployment?

"dgk" <dg*@somewhere. comwrote in message
news:8h******** *************** *********@4ax.c om...
On Mon, 19 Mar 2007 10:30:47 -0400, "sloan" <sl***@ipass.ne twrote:
Public Shared Function FindPhysicalRoo tDirectory(ByVa l p As Page) As
String

Dim rootDir As String

rootDir = p.Server.MapPat h("~/")

Return rootDir

End Function

Thanks, I select this one being a VB guy. But is there some reason not
to just do:

Dim rootDir as String = p.Server.MapPat h("~/")

or even just

Return p.Server.MapPat h("~/")
I'm not sure what any of them get you over just throwing MapPath("~/")
into the code?

Mar 20 '07 #6

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

Similar topics

0
2646
by: Don Stevic | last post by:
I am running VS2005 and using VSTO for Word. I keep getting this error saying that there is no source code available for this location when I try and run this application. I am going to try and reinstall Office 2003 and see if that fixes this, but it is talking about the mscorlib.dll and that isn’t Office.
2
2106
by: David Hearn | last post by:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. SQLExpress database file...
0
321
by: Don Stevic | last post by:
I am running VS2005 and using VSTO for Word. I keep getting this error saying that there is no source code available for this location when I try and run this application. I am going to try and reinstall Office 2003 and see if that fixes this, but it is talking about the mscorlib.dll and that isn’t Office.
15
4204
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers mapped to the local devleopment folder. Project compiles to a subfolder .\bin. To deploy, the asmx page and bin subfolder are copied to the production...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.