Kash
Threadersteller
Dabei seit: 07.11.2002
Ort: Schopfheim
Alter: 41
Geschlecht:
|
Verfasst Mo 03.12.2007 11:33
Titel [ASP] - OpenTextFile |
|
|
Hallo liebe Forengemeinde,
ich habe ein kleines Problem mit dem FileScripting Objekt.
Und zwar prüfe ich ob ein Textfile schon existiert und wenn ja soll eine neue Zeile geschrieben werden.
Wenn nicht soll er ein neues Textfile generiert werden.
Das generieren eines neuen Textfiles funktioniert wie es soll, nur wenn er eine neue Zeile hinzufügen soll da das File schon existiert schreibt er irgendwelche zeichen nur nicht den eigentl Text.
Folgend das Script
Code: |
Const ForReading = 1, ForWriting = 2, ForAppending = 8
pdfname = request.querystring("pdf")
filename = Server.MapPath("../downloads")
file = filename + "\" + pdfname
Set fso = CreateObject("Scripting.FileSystemObject")
datei = Server.MapPath("protokoll/log" & year(date) & month(date) & ".csv")
If fso.FileExists(datei) Then
Set textstream = fso.OpenTextFile(datei, ForAppending, false)
inhalt = "Benutzer: " & Session("Benutzer") & " Datei: " & pdfname & ";"
textstream.WriteLine inhalt
textstream.close
Set textstream = nothing
Set fso = nothing
Else
Set textstream = fso.CreateTextFile(datei, 8, true)
inhalt = "Benutzer: " & Session("Benutzer") & " Datei: " & pdfname & ";"
textstream.writeline inhalt
textstream.close
Set textstream = nothing
Set fso = nothing
End If
Response.AddHeader "Content-Disposition","attachment;filename=" & pdfname
Response.BinaryWrite getBinaryFile(file)
|
weiß jemand einen Tipp von euch?
gruß und danke
kash
|
|