Answered by:
Get a blank thumbnail after rename

Question
-
I'm just a hobby programer, so my programs are rather simple,but I'm learning a little. My problem is that once I use My.Computer.fileSystem.RenameFile it gives me a blank thumbnail where once there was a pic thumbnail. It renames the file properly, everything seems to work correctly except it also changes it to a blank thumbnail.
Imports System.IO Public Class Form1 Dim str As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog() 'do not show the new folder button MyFolderBrowser.ShowNewFolderButton = False If dlgResult = Windows.Forms.DialogResult.OK Then str = MyFolderBrowser.SelectedPath Label1.Text = str End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim di As DirectoryInfo = New DirectoryInfo(str) Dim HeightTemp As Integer Dim IsNumericTemp As Boolean Dim fileTemp, PicTemp, LeftTemp, RightTemp, SaveTemp As String Dim lengthTemp As Long For Each fi In di.GetFiles() 'file name fileTemp = fi.Name 'file name with path PicTemp = str & "\" & fileTemp Dim bm As New Bitmap(PicTemp) HeightTemp = bm.Height bm.Dispose() lengthTemp = Len(fileTemp) lengthTemp = lengthTemp - 4 LeftTemp = Microsoft.VisualBasic.Left(fileTemp, lengthTemp) RightTemp = Microsoft.VisualBasic.Right(LeftTemp, 1) If IsNumericTemp <> IsNumeric(RightTemp) Then GoTo skip Else SaveTemp = LeftTemp & " " & HeightTemp My.Computer.FileSystem.RenameFile(PicTemp, SaveTemp) End If skip: Next MsgBox("Finished renaning Files") End Sub End Class
Maybe somebody out there can find my mistake!Mario
Friday, January 4, 2013 4:13 AM
Answers
-
Hi,
you save the file without its Exrtension.
SaveTemp = LeftTemp & " " & HeightTemp & fi.Extension
Regards,
Thorsten
- Proposed as answer by Paul IshakModerator Sunday, January 6, 2013 10:00 PM
- Marked as answer by Mike FengModerator Monday, January 7, 2013 9:44 AM
Friday, January 4, 2013 5:55 AM
All replies
-
Hi,
you save the file without its Exrtension.
SaveTemp = LeftTemp & " " & HeightTemp & fi.Extension
Regards,
Thorsten
- Proposed as answer by Paul IshakModerator Sunday, January 6, 2013 10:00 PM
- Marked as answer by Mike FengModerator Monday, January 7, 2013 9:44 AM
Friday, January 4, 2013 5:55 AM -
In addition to Thorsten,
YOu do it difficult while it can be done easy by using the IO.Path class.
Don't be afraid of all those road signs on that page, seems to be the new way of Microsoft.
It is very easy, samples in the bottom.
http://msdn.microsoft.com/en-us/library/vstudio/system.io.path(v=vs.110).aspx
Success
CorFriday, January 4, 2013 9:00 AM -
Thanks a lotThorsten! Usinging the extension solved the problem. It is amazing that an oversight so small can make such a difference. I assumed that the extention was automaticly added. Boy was I wrong. I won't make that mistake again, but I'm sure I'll make others.
Mario
Sunday, January 6, 2013 6:49 PM