0

I am currently working on a console application which will retrieve information in a database to insert them into another database. I would like that once all data saved the application automatically generates and downloads a csv file on the user's computer. But without saving the file on the server.

Is this possible or do I have to create a temporary file?

Thank you in advance for your answers.

hardkoded
  • 18,915
  • 3
  • 52
  • 64
Space
  • 124
  • 1
  • 13
  • What server? You said this was a console application. A CSV file is just a string like any other, you can write it wherever you like. It's not really clear what the problem is. – David Aug 23 '17 at 14:44
  • Does this help, Space? https://stackoverflow.com/questions/2422212/how-to-create-csv-excel-file-c – DanielG Aug 23 '17 at 14:44
  • FileStream filestream = new FileStream("loopdata.csv", FileMode.Create); var streamwriter = new StreamWriter(filestream); streamwriter.AutoFlush = true; Console.SetOut(streamwriter); Console.SetError(streamwriter); – DanielG Aug 23 '17 at 14:45

1 Answers1

1

If the console application is running on the users PC simply saving the file like you would normally would save it to the PC the console app is running on:

System.IO.File.WriteAllText(@"C:\Wherever\WriteText.csv", text);
Alen Genzić
  • 1,398
  • 10
  • 17