1

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?

Gary Willoughby
  • 50,926
  • 41
  • 133
  • 199

4 Answers4

1

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?

Community
  • 1
  • 1
Kev
  • 118,037
  • 53
  • 300
  • 385
0

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

Nickolay Olshevsky
  • 13,706
  • 1
  • 34
  • 48
0

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.

Caerbanog
  • 1,295
  • 1
  • 12
  • 18
-2

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.

Jeff MacDonald
  • 588
  • 3
  • 2