|
-
Jan 16th, 2013, 03:40 PM
#1
Thread Starter
New Member
[RESOLVED] Adding characters to file name to prevent overwriting?
Hi, I'm making a small application where the user inputs some files in a listbox, and then the files are converted and saved in a folder. However, I still don't know how to make it see if there are files with the same name inside the listbox. So, for example if there are two files called "FileX", it will convert each one and save them, but the last converted one will replace the first one. Also, it will replace any file in that folder with the same name.
I want my application to see if there are files with the same name in that folder, and if there are, add a "(1)" to the last converted file, and if there's already a file with "(1)" in its name, add 1, so it would be a "(2)", "(3)" and so on.
My code is this:
Code:
Dim W As IO.StreamWriter
Dim i As Integer
W = New IO.StreamWriter("C:\Myprogram\Converting.bat")
For i = 0 To listbox1.Items.Count - 1
Dim getname As String
getname = System.IO.Path.GetFileName(listbox1.Items.Item(i))
'I think the code should be here
W.WriteLine(*options* & System.IO.Path.GetFileNameWithoutExtension(listbox1.Items.Item(i)) & ".converted" '& some code in here?)
Next
W.Close()
Sorry if I don't provide much code, I'm still learning.
Any help would be appreciated.
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|