DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: File Rename Problem

  1. #1
    Join Date
    Aug 2006
    Posts
    1

    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);

  2. #2
    Join Date
    Aug 2003
    Posts
    313
    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

  1. copy and rename file with ActiveX and dts
    By rkiss in forum Database
    Replies: 2
    Last Post: 02-10-2006, 12:51 PM
  2. End of file problem
    By rssmps in forum C++
    Replies: 5
    Last Post: 10-20-2005, 03:08 PM
  3. Log file problem in workflow.
    By Lakshmeenarayana G G in forum Enterprise
    Replies: 0
    Last Post: 02-07-2002, 11:57 PM
  4. PST file problem
    By Kai in forum Enterprise
    Replies: 1
    Last Post: 10-20-2001, 05:47 PM
  5. Problem loading recordset from XML file
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center