Help Creating Text File

Results 1 to 5 of 5

Thread: Help Creating Text File

  1. #1
    Join Date
    Dec 1969
    Posts
    146

    Default Help Creating Text File

    This is my first attempt at using the FileSystemObject to create a text file. I am not adding anything to the text file at this time, only attempting to creat and then delete a text file to test permissions with the code below:<BR><BR>&#060;%<BR> Dim objFSC<BR> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR> textfilename= objFSO.GetTempName<BR><BR> Set objTS=objFSO.CreateTextFile(Server.MapPath("/") & textfilename)<BR> <BR> objTS.Close<BR> Set objTS = nothing <BR> objFSO.DeleteFile Server.MapPath("/") & textfilename, False <BR> Set objFSO = Nothing <BR>%&#062;<BR><BR><BR>I get permission denied on the create text file line 6. if I had the correct permissions, would this code work? Is there a way to figure out the permissions through an ASP page of a remotely hosted server? Anyone who has used CrystalTech as their host, do they allow write and full access for this purpose as the FAQ says it is required? If not, is this something I can request? <BR><BR>How would I add the results of a recordset to the textfile? Would I need to do objTS.WriteLine or am I barking up the wrong tree? <BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969
    Posts
    18,177

    Default CrystalTech's Control Panel..

    .. allows you to give the directory Write permissions to the Everyone (I think that&#039;s what it&#039;s called on there) account.<BR><BR>You may want to move this into a subfolder so that you don&#039;t have to give Write permissions to your entire site.

  3. #3
    Join Date
    Dec 1969
    Posts
    146

    Default I will look into it

    thanks ;) does the code look good before I change the permissions and kill the server :)

  4. #4
    Join Date
    Dec 1969
    Posts
    146

    Default So I moved the file to a subdirectory

    and modified the permissions on that directory to allow read, write, execute and delete for everyone on the sub directory at Crystal Tech and still get a permissions denied error. Any suggestions?


  5. #5
    Join Date
    Dec 1969
    Posts
    18,177

    Default RE: So I moved the file to a subdirectory

    Try this code:<BR>Dim oFs: Set oFS = Server.CreateObject("Scripting.FileSystemObject")< BR>Dim oTs: Set oTs = oFs.OpenTextFile(Server.MapPath("out/Temp.txt"), 8, True) &#039;8=ForAppend<BR> oTs.Write "The cat in the hat." & vbCrLf<BR> oTs.Close<BR>Set oTs = Nothing<BR><BR>That code will create a text file called "Temp.txt" in the "out" folder. The "out" folder needs to have Write permissions on it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •