-
File Rename Problem
Hi all,
My problem is sometime i cant rename the filename with my program. For example, before i edit the content of particular file, the filename is file_01.xml, then after i edit it and click the save button, i want to rename the filename to file_01_edited.xml. So, sometime it work but sometime not.
Below is my some coding. Anybody can help me? !0s first.....
String nfilename = tokenString[0] + "_edited";
File original = new File(directoryname + "\\" + "original" + "\\" + tokenString[0] + ".txt");
File noriginal = new File (directoryname + "\\" + "original" + "\\" + nfilename + ".txt");
boolean success1 = original.renameTo(noriginal);
File process = new File(directoryname + "\\" + "process" + "\\" + tokenString[0] + ".xml");
File nprocess = new File (directoryname + "\\" + "process" + "\\" + nfilename + ".xml");
boolean success2 = process.renameTo(nprocess);
File edit = new File(directoryname + "\\" + "edit" + "\\" + tokenString[0] + ".xml");
File nedit = new File(directoryname + "\\" + "edit" + "\\" + nfilename + ".xml");
boolean success3 = edit.renameTo(nedit);
-
As a fail safe, you might try a raw byte copy from the source file to the destination file if the rename fails. Is the renameTo function returning false, or is it throwing an exception?
~evlich
Similar Threads
-
By rkiss in forum Database
Replies: 2
Last Post: 02-10-2006, 12:51 PM
-
Replies: 5
Last Post: 10-20-2005, 03:08 PM
-
By Lakshmeenarayana G G in forum Enterprise
Replies: 0
Last Post: 02-07-2002, 11:57 PM
-
By Kai in forum Enterprise
Replies: 1
Last Post: 10-20-2001, 05:47 PM
-
By Santiago in forum VB Classic
Replies: 0
Last Post: 03-20-2001, 05:04 PM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|