By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 1,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

How to read a text file in the website?

P: n/a
I feel stupid for asking this but I can't figure this out. I've got some
text files I want my website to read. The text files are located in a
subdirectory of my application. Physically, the files are located on drive
C: in directory starting with InetPub/myapplication/directrory/files .
Thing is,when the website is running, the application path is
c:\windows\system32. I can manipulate the path to get this to work for now.
Thing is, once the application is done it may not be installed on Drive C:
much less under InetPub. What's the best way to get the path of the these
text files and access them? The files are stored in subdirectory of my
webprojoct called /emails. Thanks!

Chris Smith
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You can use Server.MapPath method to get physical location of file
located in web applications directory.
Also you'll need to set rights to access this file for ASPNET user..

Tomas Petricek
Microsoft C# MVP

-----Original Message-----
From: who be dat? [mailto:wh******@dot.com]
Posted At: Saturday, July 31, 2004 7:35 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: How to read a text file in the website?
Subject: How to read a text file in the website?

I feel stupid for asking this but I can't figure this out. I've got
some
text files I want my website to read. The text files are located in a
subdirectory of my application. Physically, the files are located on
drive
C: in directory starting with InetPub/myapplication/directrory/files .
Thing is,when the website is running, the application path is
c:\windows\system32. I can manipulate the path to get this to work for
now.
Thing is, once the application is done it may not be installed on Drive
C:
much less under InetPub. What's the best way to get the path of the
these
text files and access them? The files are stored in subdirectory of my
webprojoct called /emails. Thanks!

Chris Smith
Nov 18 '05 #2

P: n/a
Bah!! I forgot about MapPath. Grrr...

Now about this access for ASP.Net. As long as the directory is in the
project I created, all files in this directory should have such access,
right? I just tried this on my machine and it was able to retrieve and read
the text file from this directory just fine. I'm concerned when I release
this application and let others use it. Will they have to do something to
this directory.

Thanks for the help and the quick response.

Chris Smith

"Tomas Petricek" <to***@eeeksoft.net> wrote in message
news:uv**************@TK2MSFTNGP09.phx.gbl...
You can use Server.MapPath method to get physical location of file
located in web applications directory.
Also you'll need to set rights to access this file for ASPNET user..

Tomas Petricek
Microsoft C# MVP

-----Original Message-----
From: who be dat? [mailto:wh******@dot.com]
Posted At: Saturday, July 31, 2004 7:35 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: How to read a text file in the website?
Subject: How to read a text file in the website?

I feel stupid for asking this but I can't figure this out. I've got
some
text files I want my website to read. The text files are located in a
subdirectory of my application. Physically, the files are located on
drive
C: in directory starting with InetPub/myapplication/directrory/files .
Thing is,when the website is running, the application path is
c:\windows\system32. I can manipulate the path to get this to work for
now.
Thing is, once the application is done it may not be installed on Drive
C:
much less under InetPub. What's the best way to get the path of the
these
text files and access them? The files are stored in subdirectory of my
webprojoct called /emails. Thanks!

Chris Smith

Nov 18 '05 #3

P: n/a
Read access should not be a problem, unless someone went and changed it
for the subdirectory. If you are planning to write to this file, then
you would have to grant Write access as this would be defaulted to
denied, but remember that if anyone requested for the Text file, it
will server to the client browser. So you should not place any sensitive
information in this file.

Regards,

Trevor Benedict R

Nov 18 '05 #4

P: n/a
Thanks both of you. You were a big help.

Chris Smith

"Trevor Benedict R" <tr********@yahoo.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Read access should not be a problem, unless someone went and changed it
for the subdirectory. If you are planning to write to this file, then
you would have to grant Write access as this would be defaulted to
denied, but remember that if anyone requested for the Text file, it
will server to the client browser. So you should not place any sensitive
information in this file.

Regards,

Trevor Benedict R

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.