How can i rename the files once the file is open?
For example : When I open first file the file will rename under '1.jpg', then if I open second file the file name will rename under '2.jpg' and so on.
Below code are use to open the files.
System.Diagnostics.Process.Start("C:\Users\hwai\Desktop\Capture\Example.jpg")
Thanks
How can you rename an open file? Files are not supposed to be renamed while opened. How could the application that has the file open access the file if the file was renamed by some other application?
The forget to mention in the below information quoted from the above link that an exception can be caused if the file to be renamed is in use by another application. Or if the other application does not have the file locked it may crash if it tries to do something with the file and the file is renamed while it is referencing the old path/filename.
"The following conditions may cause an exception:
The path is not valid for one of the following reasons: it is a zero-length string, it contains only white space, it contains invalid characters, or it is a device path (starts with \\.\) (ArgumentException ).
newName contains path information (ArgumentException ).
The path is not valid because it is Nothing (ArgumentNullException ).
newName is Nothing or an empty string (ArgumentNullException ).
The source file is not valid or does not exist (FileNotFoundException ).
There is an existing file or directory with the name specified in newName (IOException ).
The path exceeds the system-defined maximum length (PathTooLongException ).
A file or directory name in the path contains a colon (:) or is in an invalid format (NotSupportedException ).
The user lacks necessary permissions to view the path (SecurityException ).
The user does not have the required permission (UnauthorizedAccessException )."
La vida loca
No comments:
Post a Comment