Usher
Usher

Reputation: 2146

best and effective way to rename the file

I have a wpf application and inside using Image resizer as a third party tool in that app. I am trying to achieve the following scenario:

I have text box (Employee Name) for example "Madona"
I have a image text box linked with third party tool "Image Resizer".

If i choose the image (eg: Madona123.jpg), the Image resizer will generate 17 different size images and drop it in my source folder (e.g. Madona123_80x60.jpg, Madona123_150x150.jpg, etc..)

But am trying to change the file name like e.g: Madona_80x60.jpg, Madona_150x150.jpg

I have two options but not sure which one is effective

Am not sure which one is best and what other concerns i have to look ,thanks for your input.

Upvotes: 1

Views: 367

Answers (2)

XikiryoX
XikiryoX

Reputation: 1928

From your suggested scenarios I would go for option 2.

  • As you stated, creating an extra temp folder might cause rights issues so if you're not entirely certain about the setup of the machines that will be using the app then option 1 might be causing your app to fail.
  • As a secondary (and very minor) reason, option 2 will, even if it doesn't fail on rights still create an extra folder. If you would choose to make that temp folder part of your application, people have the tendency of removing temp folders and their contents.. Or you might create it every time on startup of the app, but that also requires, a little bit, coding. (altough point taken, this is just a minor reason and not really a reason that would tip the scales..)

I do agree with Blam's statement that option one would make the base coding a bit more simple but I think aldo the bit of extra work, option 2 will give you less possibility for failure.

So if you're gonna be using it in a manageable environment where you know the setup of your targetmachines, go with option one, it requires less and more straightforward coding, if you're gonna be using it in any other sort of environment, go with option 2. It 'll give you the highest chance of success.

Upvotes: 0

paparazzo
paparazzo

Reputation: 45096

Option 1 has an extra copy command - you can rename when you copy. But with option 2 you have multiple renames. I would do 1 for simplicity.

Upvotes: 2

Related Questions