Worf Posted April 11, 2009 Posted April 11, 2009 Hi again. I have another problem that i need to solve to get my program to work correctly. I need a routine or a couple of lines that will remove the following characters from filenames. These are Spaces, "." and "_" the one a found does not seem to work. :( Many Thanks for you help Worf Quote
JumpyNET Posted April 14, 2009 Posted April 14, 2009 Is this what you are looking for? Dim FullPath As String = "C:\My_Dir\Just_A.File_Name.txt" Dim FileNameOnly As String = IO.Path.GetFileNameWithoutExtension(FullPath) FileNameOnly = Replace(FileNameOnly, "_", "") FileNameOnly = Replace(FileNameOnly, ".", "") FullPath = IO.Path.Combine(IO.Path.GetDirectoryName(FullPath), _ FileNameOnly & IO.Path.GetExtension(FullPath)) Debug.Print(FullPath) Quote
Worf Posted April 14, 2009 Author Posted April 14, 2009 Is this what you are looking for? Dim FullPath As String = "C:\My_Dir\Just_A.File_Name.txt" Dim FileNameOnly As String = IO.Path.GetFileNameWithoutExtension(FullPath) FileNameOnly = Replace(FileNameOnly, "_", "") FileNameOnly = Replace(FileNameOnly, ".", "") FullPath = IO.Path.Combine(IO.Path.GetDirectoryName(FullPath), _ FileNameOnly & IO.Path.GetExtension(FullPath)) Debug.Print(FullPath) Hi JumpyNET Thank you for your reply. This looks like just what i need, if this works i can delete the routine that removes the extention as this routine will make things alot easier for me. Many Thanks Worf Quote
Worf Posted April 14, 2009 Author Posted April 14, 2009 Hi JumpyNET Thank you for your reply. This looks like just what i need, if this works i can delete the routine that removes the extention as this routine will make things alot easier for me. Many Thanks Worf Doesn't work :( Not removing characters Quote
JumpyNET Posted April 14, 2009 Posted April 14, 2009 Doesn't work :( Not removing characters Could you please give an example string that you want to process. Or maybe a little of you current code. Quote
Worf Posted April 15, 2009 Author Posted April 15, 2009 Could you please give an example string that you want to process. Or maybe a little of you current code. It ok, got it working now. Many Thanks Worf Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.