How to Append to a File via FTP

S

Simone M

Here is my problem: I need to append a string to a file every time the
user downloads this file. The string is different for every user. I
would like to append the string to the file via ftp. But I am not sure
how I can do this, I've never written an FTP client. Which class can I
use to do this? Is it possible to append to a file that already is in
an FTP server? Will the FTPWebRequest class work?
Thanks in advance for your ideas,
Simone
 
M

Mr Flibble

* Simone M said:
Here is my problem: I need to append a string to a file every time the
user downloads this file. The string is different for every user. I
would like to append the string to the file via ftp. But I am not sure
how I can do this, I've never written an FTP client. Which class can I
use to do this? Is it possible to append to a file that already is in
an FTP server? Will the FTPWebRequest class work?

To append to a file you'd have to retrieve the file, append your data,
and upload the altered file. This is how FTP works, it's designed for
transfering files it's not a fileserving application with normal file
access semantics.

Mr Flibble
 
K

Kevin Spencer

I'm not following you. It *sounds* like you are working from the server end,
and that when an FTP client requests a file, it is appended to prior to
attaching it to the response stream. If so, you don't need to create an FTP
client, but an FTP server. And the server app would not need FTP to append
to the file, which is on the server. It would append to it prior to
returning it. OTOH, if you are working with an FTP client that downloads
files, and youy want to append to the downloaded file, there is also no need
to do it via FTP. The client app can append to the downloaded file prior to
returning it or saving it.

Perhaps you should outline the actual requirements for your app, rather than
the methodology you think you need to employ to satisfy those requirements.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 
S

Simone M

You got my point. But I was looking to save on bandwidth, since it's a
large file, and having to retrieve the file costs bandwith. I wish I
could just do some cutting/appending operations on the file, but I
guess it's not possible without having to retrieve it ???
Thanks,
Simone
 
S

Simone M

Thanks Kevin.
You have lead me to the right direction. I was thinking wrong. I don't
need to use FTP. I could append the data to the file on the server
before the user downloads it since I have acess to the file on the
server. I guess this is a common problem.
Just a question: What do you mean by Response Stream?
Can't I accomplish this by just using a FileStream?
 
K

Kevin Spencer

Hi Simone,

If you want to append to the file before returning it, you're going to have
to handle the FTP Request. That means that you need to write an FTP server
that will receive the RETR command, fetch the file specified, append to it,
and then send the appended file to the client.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top