Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Max limits on Write in Scripting.FileSystemObject

1,918 views
Skip to first unread message

teppic

unread,
Feb 6, 2008, 5:30:31 AM2/6/08
to
Hi,

I am trying to implement ASP caching on my website by writing out the
page created into a file. The problem is when I try to write in a page
that is longer than 9147 characters it doesnt write it to the file,
but does if equal or under this figure. Is there any maximum to the
amount of chars that can be written into the file.

NOTE: It does work if I create the file using TristateTrue (unicode),
but not in TristateFalse (ASCII) which is what I want.

Extract of the code is as follows:

'Create file system object
Set cache_FILEOBJ = Server.CreateObject("Scripting.FileSystemObject")

'grab the contents of the page
Set objHTTP = Server.CreateObject("MSXML2.XMLHTTP")
objHTTP.open "GET", "http://www.mywebsite.com/mypagetocache.asp",
false
objHTTP.send()

'output results to screen
Dim strTextResponse : strTextResponse = objHTTP.responseText
set objHTTP = nothing
Response.write strTextResponse

'create cache text file
Set cache_FILETXT =
cache_FILEOBJ.OpenTextFile(Server.Mappath("cachefiles/mypagetocache" &
".txt"),2,True,-2)

'save results
cache_FILETXT.Write strTextResponse

'clean up
cache_FILETXT.Close()
Set cache_FILETXT = nothing

ekkehard.horner

unread,
Feb 6, 2008, 6:18:00 AM2/6/08
to
teppic schrieb:

> Hi,
>
> I am trying to implement ASP caching on my website by writing out the
> page created into a file. The problem is when I try to write in a page
> that is longer than 9147 characters it doesnt write it to the file,
> but does if equal or under this figure. Is there any maximum to the
> amount of chars that can be written into the file.
>
> NOTE: It does work if I create the file using TristateTrue (unicode),
> but not in TristateFalse (ASCII) which is what I want.
>
[...]

This code:

Const cnBSize = 10000
Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" )
Dim sFiNa : sFiNa = ".\wtfile."
' 1569 0621 ARABIC LETTER HAMZA
Dim aUChars : aUChars = Array( "A", ChrW( 1569 ) )
Dim aEnc : aEnc = Array( "ascii", False, "utf16", True )

Dim sUChar, sText, nEnc, sFSpec, oTS
For Each sUChar In aUChars
WScript.Echo "UChar:", AscW( sUChar ), "-------------------"
sText = String( cnBSize, "x" ) & sUChar & String( cnBSize, "x" )
For nEnc = 0 To UBound( aEnc ) Step 2
sFSpec = sFiNa & aEnc( nEnc )
WScript.Echo sFSpec
Set oTS = oFS.CreateTextFile( sFSpec, True, aEnc( nEnc + 1 ) )
On Error Resume Next
oTS.Write sText
If 0 <> Err.Number Then WScript.Echo "**** Error:", Err.Description
On Error GoTo 0
oTS.Close
WScript.Echo "Size", oFS.GetFile( sFSpec ).Size
WScript.Echo
Next
Next

output:

=== writeToFile: write to file encoding/size test =================
UChar: 65 -------------------
.\wtfile.ascii
Size 20001

.\wtfile.utf16
Size 40004

UChar: 1569 -------------------
.\wtfile.ascii
**** Error: Ungültiger Prozeduraufruf oder ungültiges Argument
Size 0

.\wtfile.utf16
Size 40004

=== writeToFile: 0 done (00:00:00) ================================

should prove that the problem is saving text containing at least one
unicode character not convertable to ascii (=current locale/codepage)
to an ascii file.

teppic

unread,
Feb 6, 2008, 8:50:37 AM2/6/08
to
On 6 Feb, 11:18, "ekkehard.horner" <ekkehard.hor...@arcor.de> wrote:
> teppic schrieb:> Hi,
>
[..]

>
> should prove that the problem is saving text containing at least one
> unicode character not convertable to ascii (=current locale/codepage)
> to an ascii file.

That is it, it was a problem with a character not convertable to
ascii.. thank you!

0 new messages