0

in my WinFormsApp user can add picture in a folder of hardDrive with SaveFileDialog. if there is a picture the same name as new picture an alert is shown that user must rename the new picture.

how can I change name of the picture with adding a variable integer to name without changing name with user?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
user1837982
  • 93
  • 1
  • 1
  • 7

1 Answers1

0

The SaveFileDialog class has a public FileName property that allows you to get or set the file name displayed in the dialog box.

This is how you retrieve the file name that the user specified after they have dismissed the dialog box, but it is also the way that you specify a default file name that initially appears in the dialog box.

So before you call the SaveFileDialog.ShowDialog method, just set the FileName property to the desired file name. If you like, you can retrieve its current value, append a number to it, and set the property to the new string.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • thanks but I know how to change name my problem is How can I understand there is another picture as same as new picture – user1837982 May 11 '13 at 07:32
  • So then, what is your question? How do you append a number to a string? Use the `+` operator. See also [this question](http://stackoverflow.com/questions/9418815/adding-integers-to-strings-in-c-sharp). – Cody Gray - on strike May 11 '13 at 07:33
  • thanks but I know how to change name my problem is How can I understand there is another picture as same as the name of new picture – user1837982 May 11 '13 at 07:36
  • 1
    I guess you're asking about the [`OverwritePrompt`](http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.overwriteprompt.aspx) property? – Cody Gray - on strike May 11 '13 at 07:37