简体   繁体   中英

change name of file in SaveFileDialog

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM