Error Creating TXT File

R

ruca

Private Sub find_file(ByVal strFile)
Dim Path As String
Dim NewFile As StreamWriter

strFile = "Extern\" & strFile
Path = Server.MapPath(strFile)
If Not File.Exists(Path ) Then
NewFile = File.CreateText(Path )
NewFile .Close()
End If
End Sub


I have this to find (and create, if not found) a file. The problem is that
it's not working.
It gives me an error like this:
Access to the path "c:\(all path)\Extern\novo.txt" is denied

I think that I have to set permissions, but where??? I already put the Read
an Write Permissions for that application in IIS, and in the right path too.

How can I set this up?
It's missing anything?
 
M

Martin Dechev

Hi, ruca,

You should allow Modify and Write rights to the local ASPNET account for
that folder. In the Windows Explorer right-click and choose Properties and
then choose the tab Security. If you don't see the ASPNET account in the
list add it.

Hope this helps
Martin
 
R

ruca

Ok, it works!!!
Now I have another thing.... It's to Read each line of that TXT file. For
that I have this:

Function ReadTXT()
Dim stmReader As StreamReader
Dim Path As String

Path = Server.MapPath("Extern\novo.txt")

VerUser = File.OpenText(LerPath)
While Not VerUser.ReadToEnd()
txtLine = VerUser.ReadLine()
'then I have code here but it's only to format the sesult line
End While
End Function

txtLine result is always Nothing and because of that the While instruction
don't end.
Can you help me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top