Error Creating TXT File

Discussion in 'ASP .Net Web Controls' started by ruca, Mar 3, 2004.

  1. ruca

    ruca Guest

    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?


    --

    Thank's (if you try to help me)
    Hope this help you (if I try to help you)
    ruca
    ruca, Mar 3, 2004
    #1
    1. Advertising

  2. 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
    "ruca" <> wrote in message
    news:...
    > 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?
    >
    >
    > --
    >
    > Thank's (if you try to help me)
    > Hope this help you (if I try to help you)
    > ruca
    >
    >
    >
    >
    >
    Martin Dechev, Mar 3, 2004
    #2
    1. Advertising

  3. ruca

    ruca Guest

    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?


    --

    Thank's (if you try to help me)
    Hope this help you (if I try to help you)
    ruca


    "Martin Dechev" <> escreveu na mensagem
    news:...
    > 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
    > "ruca" <> wrote in message
    > news:...
    > > 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?
    > >
    > >
    > > --
    > >
    > > Thank's (if you try to help me)
    > > Hope this help you (if I try to help you)
    > > ruca
    > >
    > >
    > >
    > >
    > >

    >
    >
    ruca, Mar 3, 2004
    #3
  4. Hi, ruca,

    The MSDN documentation is full of examples, just browse around the classes
    you use.

    Anyway, try adapting this example for your needs:

    http://msdn.microsoft.com/library/en-us/cpguide/html/cpconreadingtextfromfile.asp

    Hope this helps
    Martin
    "ruca" <> wrote in message
    news:...
    > 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?
    >
    >
    > --
    >
    > Thank's (if you try to help me)
    > Hope this help you (if I try to help you)
    > ruca
    >
    >
    > "Martin Dechev" <> escreveu na mensagem
    > news:...
    > > 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
    > > "ruca" <> wrote in message
    > > news:...
    > > > 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?
    > > >
    > > >
    > > > --
    > > >
    > > > Thank's (if you try to help me)
    > > > Hope this help you (if I try to help you)
    > > > ruca
    > > >
    > > >
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Martin Dechev, Mar 3, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ruca

    Error Creating TXT File

    ruca, Mar 3, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    503
    Martin Dechev
    Mar 3, 2004
  2. Polvere@Lab
    Replies:
    4
    Views:
    280
    Mike Wahler
    Aug 29, 2005
  3. Sameen
    Replies:
    2
    Views:
    432
    Victor Bazarov
    Aug 29, 2005
  4. Creating .txt file

    , May 10, 2007, in forum: C++
    Replies:
    3
    Views:
    281
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=
    May 10, 2007
  5. Jochen Brenzlinger
    Replies:
    7
    Views:
    5,527
    Roedy Green
    Sep 15, 2011
Loading...

Share This Page