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



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 FindPhysicalRootDirectory(Page p)
{
string rootDir;
rootDir = p.Server.MapPath("~/");
return rootDir;
}




Public Shared Function FindPhysicalRootDirectory(ByVal p As Page) As
String

Dim rootDir As String

rootDir = p.Server.MapPath("~/")

Return rootDir

End Function


I have another counter part:

public static string FindVirtualRootDirectory(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" <NoWhere@xxxxxxxxxxxxxxxxxx> wrote in message
news:rpapv257kb5pf116g0e8l2m0rt0v4i1rst@xxxxxxxxxx
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.


.