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

How to read a text file?

Hi,

I add a folder to my web application, the folder name is "Text" and I put
one text file (1.txt) in the folder. in Default.aspx.vb load event, I try to
open this text file:

dim fs as new io.filestream(server.mappath("test\1.txt"),filemod e.open)
dim sr as new io.streamreader(fs)
dim s as string=sr.readtoend
sr.close

response.write (s)

I got a error saying "access to path <pathis denied".

How do I resolve this problem?

Regards

Quinn
Apr 7 '08 #1
2 1217
Usually "access denied" is resolved by giving permissions to the appropriate
account.

In your case it's ASPNET account... needs to have "Read" permissions.

Also change this
dim fs as new io.filestream(server.mappath("test\1.txt"),filemod e.open)

to
dim fs as new io.filestream(server.mappath("test\1.txt"),filemod e.open,
FileAccess.Read)

otherwise it will require write/modify permissions as well
George.

"Quinn" <qj**@yahoo.comwrote in message
news:el****************@TK2MSFTNGP06.phx.gbl...
Hi,

I add a folder to my web application, the folder name is "Text" and I put
one text file (1.txt) in the folder. in Default.aspx.vb load event, I try
to open this text file:

dim fs as new io.filestream(server.mappath("test\1.txt"),filemod e.open)
dim sr as new io.streamreader(fs)
dim s as string=sr.readtoend
sr.close

response.write (s)

I got a error saying "access to path <pathis denied".

How do I resolve this problem?

Regards

Quinn

Apr 7 '08 #2
You need to make sure the ASP.NET running user account (hopefully, you know
which user account is used/configured by you to run the ASP.NET application)
have at least "read" permission to that folder.

"Quinn" <qj**@yahoo.comwrote in message
news:el****************@TK2MSFTNGP06.phx.gbl...
Hi,

I add a folder to my web application, the folder name is "Text" and I put
one text file (1.txt) in the folder. in Default.aspx.vb load event, I try
to open this text file:

dim fs as new io.filestream(server.mappath("test\1.txt"),filemod e.open)
dim sr as new io.streamreader(fs)
dim s as string=sr.readtoend
sr.close

response.write (s)

I got a error saying "access to path <pathis denied".

How do I resolve this problem?

Regards

Quinn
Apr 7 '08 #3

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

Similar topics

3
by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to...
1
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
3
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
3
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT...
3
by: Ray | last post by:
Hello World, I made a Windowsform that reads data from a CSV file. It works fine, but when I have read the data of a record I have to re-Debug the form to read another record. So when I put a...
6
by: Thomas Kowalski | last post by:
Hi, currently I am reading a huge (about 10-100 MB) text-file line by line using fstreams and getline. I wonder whether there is a faster way to read a file line by line (with std::string line)....
6
by: portCo | last post by:
Hello there, I am creating a vb application which is some like like a questionare. Application read a text file which contains many questions and display one question and the input is needed...
0
by: alivip | last post by:
Is python provide search in parent folder contain sub folders and files for example folder name is cars and sub file is Toyota,Honda and BMW and Toyota contain file name camry and file name corola,...
4
by: Keith G Hicks | last post by:
I'm trying to read a text file and alter the contents of specific lines in the file. I know how to use streamreader to read each line of a file. I'm doing that already to get the data into a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.