Question

I'm using C# and i have written a locally installed application that dynamically generates files which need to be on an FTP server.

Do i generate them to disk then upload them to the FTP server? or is there a way to open a stream to an FTP server and write the files directly?

Was it helpful?

Solution

Check the code sample I gave in this answer, doesn't rely on writing to files. It's not SQL specific and was just a suggestion on how to use SQL CLR integration assemblies to upload output from sql queries to an FTP server. The for loop in the method is just to demonstrate writing to the FTP stream. You should be able to rework to you needs:

How to write stored procedure output directly to a file on an FTP without using local or temp files?

OTHER TIPS

You should follow the class:

System.Net.FtpWebRequest

You will see that its arguments are streams and you can send data to them from any source.

When seaching for .Net capabilities you should be aware of the object browser for visual studio acessible in:

View > other windows > object browser

Is supplies a search over all known assembly .Net objects.

The better way is to save file locally, and upload it later, since there could be problems with upload process.

Since you are using c# I'm thinking maybe you are in a Windows Env. Something I know little about :)

If you are dealing with a unix env, you could just pipe your output thru SSH, which would also take care of encryption overhead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top