C# is case sensitive, so if you wanted
private string filepath = null;
And
CreateWordDocument(FilePath, SaveDoc.FileName);
To refer to the same variable, then you need to use the same case on both. If you don't, then it's a bad idea to have two variables with such similar names!
And since none of the code you show modifies the content of
filepath
it will alway be null. Did you mean to set filepath to FilePath or SaveDoc.FileName before you returned from your Save button handler?
"[1] When user saves file for 1st time, SFD will return filepath (with filename) that user chose. Store this path in some variable. [2] When save button is clicked again, check for this path variable, if it has value then skip SFD and do update logic. [3] Clear this path variable at appropriate location in code when user/that file session is completed."
Start off by changing the names! :laugh:
The idea of having a variable which holds the Save Path is good - and it works, but only if you do actually store the file path into it.
So, pseudo code!
Save function:
if Filename is not null
then
Save file to Filename
else
Use SaveFileDialog to get user choice.
if user pressed OK
then
set Filename to user choice
Save file to Filename
end
end
Save As function:
Use SaveFileDialog to get user choice.
if user pressed OK
then
set Filename to user choice
Save file
end
In your case, you don't need to clear Filename at any point, except to start it as null.
That should be pretty simple to convert to C#, yes?