1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Permission Denied on CreateTextFile

Discussion in 'C#' started by joshymraj, Aug 8, 2007.

  1. #1
    Hi all,
    SEMrush
    I am an newbie in ASP.I am trying to create a file using this code :-

    Dim objFSO ' File System Object
    Dim objFile ' File Object
    set objFSO=Server.CreateObject("Scripting.filesystemobject")
    set objFile=objFSO.CreateTextFile("test.txt",false)
    objFile.Write "Hello World"
    objFile.Close
    set objFile=nothing
    set objFSO=nothing

    But i am getting an error page saying permission denied.What could be wrong ?
    Please help.
     
    joshymraj, Aug 8, 2007 IP
    SEMrush
  2. yugolancer

    yugolancer Well-Known Member

    Messages:
    321
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Next time send entire error/exception message.
    However i'll try to guess that maybe test.txt already exists on that location so you need to set up the overwrite argument to true:
    
    set objFile=objFSO.CreateTextFile("test.txt", [B]True[/B])
    
    Code (markup):
    Otherwise set the permissions. You must give the rights to write to the directory as by default it's always only "read + scripts allowed".

    HTH
    Regards :)
     
    yugolancer, Aug 13, 2007 IP
  3. webcosmo

    webcosmo Notable Member

    Messages:
    5,842
    Likes Received:
    153
    Best Answers:
    2
    Trophy Points:
    255
    #3
    Right click on the folder->Click on Sharing and Security
    ->Check if you have write permission for your login.

    Sometimes this doesn't work either, if you are trying to create a file on server. You have to make sure you have "Users" on the admin list. Allow Users Write permission on the folder same way like above.
     
    webcosmo, Aug 13, 2007 IP
  4. shafferb1

    shafferb1 Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You may want to change the file name that it creates. If this is still a problem then it is a permission issue and you should ask your host how to change permissions. You may be able to do it via your FTP client.
     
    shafferb1, Aug 14, 2007 IP
  5. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,228
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #5
    May the directory in which you are trying to created file does not have the write permission.
     
    MayurGondaliya, Aug 21, 2007 IP