Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > File System Object question

Reply
Thread Tools

File System Object question

 
 
PedroX
Guest
Posts: n/a
 
      06-27-2005
I have about 200 documents to which I need to write a header and a footer.
Appending (the footer) is easy, but I cannot figure out how to write to the
very beginning of the file. Any help would be appreciated


 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      06-27-2005
PedroX wrote:
> I have about 200 documents to which I need to write a header and a footer.
> Appending (the footer) is easy, but I cannot figure out how to write to the
> very beginning of the file. Any help would be appreciated
>
>


put your new text into a string1,
read in the contents of the doc to string2
string1 = string1 + string2
save string1 back to the doc.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      06-27-2005
"PedroX" <> wrote in message
news:RXXve.1106$...
> I have about 200 documents to which I need to write a header and a footer.
> Appending (the footer) is easy, but I cannot figure out how to write to

the
> very beginning of the file. Any help would be appreciated


Your "documents", I gather, are text files and not MS-Word documents.

You'll have to "rewrite" to entire text file.

Use the ReadAll method to read the intial file then write your header,
the initial file, and the footer to the same file.


 
Reply With Quote
 
PedroX
Guest
Posts: n/a
 
      06-27-2005

> Use the ReadAll method to read the intial file then write your header,
> the initial file, and the footer to the same file.


Thanks 4 the replies. I guess that should work. The documents are XML files.
They are about 10 mb each. Would that be a problem?




 
Reply With Quote
 
Ken Jenkins
Guest
Posts: n/a
 
      06-27-2005
well, thats not the greatest situation to have going on.. those are big
files


"PedroX" <> wrote in message
news:VuYve.1129$...
>
>> Use the ReadAll method to read the intial file then write your header,
>> the initial file, and the footer to the same file.

>
> Thanks 4 the replies. I guess that should work. The documents are XML
> files.
> They are about 10 mb each. Would that be a problem?
>
>
>
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      06-27-2005
PedroX wrote:
>> Use the ReadAll method to read the intial file then write your
>> header, the initial file, and the footer to the same file.

>
> Thanks 4 the replies. I guess that should work. The documents are XML
> files. They are about 10 mb each. Would that be a problem?


Please don't crosspost to so many groups. This question had nothing to do
with databases (db) or components, so it was certainly off-topic in those
groups, which I've removed from this reply.

If you had mentioned from the start that you were using XML files, you would
have received a different answer. FileSystemObject is not necessary for
modifying XML . I suggest you provide a small example of what you want to
do. Are you really adding information outside of the XML? Or are you adding
nodes to the XML?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      06-27-2005
"McKirahan" wrote in message news:2-SdnWnf--wTzF3fRVn-...
: "PedroX" <> wrote in message
: news:RXXve.1106$...
: > I have about 200 documents to which I need to write a header and a
footer.
: > Appending (the footer) is easy, but I cannot figure out how to write to
: the
: > very beginning of the file. Any help would be appreciated
:
: Your "documents", I gather, are text files and not MS-Word documents.
:
: You'll have to "rewrite" to entire text file.
:
: Use the ReadAll method to read the intial file then write your header,
: the initial file, and the footer to the same file.

If you were going to do that, wouldn't this be easier?

sub appendit(file1, file2, file3, t)
dim fso, temp, tempFile, wshShell, oExec
set fso = CreateObject("Scripting.FileSystemObject")
set wshShell = CreateObject("WScript.Shell")
if fso.FileExists(file1) then
if fso.FileExists(file2) then
if fso.FileExists(file3) then
temp = fso.GetTempName
set oExec = wshShell.Exec("%comspec% /c copy " & file1 & "+" & file2
& "+" & file3 & " " & temp)
do while oExec.status = 0
wscript.sleep 100
loop
if fso.FileExists(t) then
fso.DeleteFile(t)
end if
fso.MoveFile temp, t
end if
end if
end if
wscript.echo temp
end sub

appendit "f1.txt","f2.txt","f3.txt","f4.txt"

f4.txt would be replace with the file you wanted to end up with, however, I
wouldn't use this for XML files.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File System Object - not deleting file Lise ASP General 3 06-08-2006 03:14 PM
Object reference not set to an instance of an object. System.Web.UI.WebControls.ListItemCollection.SaveViewState() System.Web.UI.WebControls.ListControl.SaveViewState() Brano ASP .Net 3 11-08-2005 12:29 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
System.Security.SecurityException: Error de solicitud de permiso de tipo System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. Luis Esteban Valencia ASP .Net 0 07-14-2005 01:43 PM
Why are sender and object used as in sender As System.Object, ByVal e As System.EventArgs? Showjumper ASP .Net 2 08-02-2003 10:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57