Hi
I need to make a program that renames a file to the date.
I'm using the command My.Computer.FileSystem.RenameFile("FILE LOCATION", "DESIRED FILENAME")
I've tryed using My.Computer.Clock.LocalTime though I get the error "Argument 'newName' must be a name, and not a relative or absolute path: '23/12/2011 13:18:50'."
Has anyone done this before?
Francis.
EDIT - I think the problem is that windows does not allow characters such as "/" and ":" meaning that a different command will have to be used. Does anyone know any?
3 replies to this topic
#1
Posted 23 December 2011 - 05:19 AM
|
|
|
#2
Posted 23 December 2011 - 08:59 AM
Try something like yourDate.ToString("yyyyMMddhhmmss")
#3
Posted 25 January 2012 - 02:35 AM
The problem here is with the
23/12/2011The "/" is an invalid character. As you can see, windows will think that you are telling it to access another directory, rather than renaming the file in that folder.
#4
Posted 25 January 2012 - 07:19 AM
Use the String.Replace() method to change the '/' characters into '-' characters.
Documentation:
String.Replace Method (Char, Char)
Documentation:
String.Replace Method (Char, Char)
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









