in .NET how to programmatically change the 'Save as' filetype and destination of a generated document?

116 views Asked by At

We have a WinForms app in which we generate files programmatically and save them in the user's temp folder before opening them with the default application for the type.

If the user clicks Save As, and then doesn't choose an alternate destination, the saved file ends up in their temp folder.

Worse still, we generate spreadsheets as CSV files, and Word docs as XML, so unless they change the file type as well, they end up with a file of the wrong type in the wrong place, and can consequently never find it again.

Ideally, we'd like to pre-set the target type and destination folder so that it's selected when they Save As.

Is this possible, or do we need a radically different approach to document generation? As you can imagine, it's very convenient to generate CSV and XML, a lot less so native document formats.

Edit...

I am, of course, aware that an XLS(X) file isn't the same as a CSV file. We generate CSV and then have Excel open them, as TS mentioned.

What I'd like to achieve, is for it to be Excel that offers XLS (or XLSX) by default, even though the file type is CSV. The SaveAs dialog comes from Excel (or Word), not from my application.

It may not be possible, in which case I have a number of options - such as automation. But it's hoops I'd rather not jump through unless I have to. Thanks.

0

There are 0 answers