1 Replies - 245 Views - Last Post: 21 June 2013 - 09:06 AM Rate Topic: -----

#1 ceyesumma  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 31
  • Joined: 14-December 10

substitute drive letters with variables in XML to maintain docs saved

Posted 21 June 2013 - 07:43 AM

I built the program and created the dir structure on C: drive only. So it always use the one slash pattern. I altimatly wanted the app to work form thumb drive only.

When I entered this phase I noticed as I jumped from one computer to the next while running the app on the thumb drive it was using the many drive letters possible with the double slash pattern.

If my program was able to evaluate a substring of a path before it was written to XML then could I enter it into my XML so no matter what machine I was using it would insert a variable in place of the ever changing drive letter. In this case K:\
 <linkPath>
K:\\.targetGuide\admin_\admin\Note Folder\CREATED ON THUMB\index
</linkPath>
  <linkPath>C:\Users\Steves\Documents\.targetGuide\admin_\admin\Note Folder\test\c drive test tab\index 
</linkPath>


  public static final String USERHOMEDIR = System.getProperty("user.dir", ".");


If I could load a variable that would tell the app how to open the files in the dir on the thumb by replacing the drive letter to what it actually is on the various machine where the thumb drive is.
public static final String USERHOMEDIR = System.getProperty("user.dir", ".");


 <linkPath>
K:\\.targetGuide\admin_\admin\Note Folder\CREATED ON THUMB\index
 </linkPath>
 <linkPath>C:\Users\Steves\Documents\.targetGuide\admin_\admin\Note Folder\test\c drive test tab\index  
</linkPath>


  public static final String USERHOMEDIR = System.getProperty("user.dir", ".");


Does this sound possible? or is there another way to maintain these paths without haveing to assume administrator
rights on the client machine?
Thanks for the insight.

Is This A Good Question/Topic? 0
  • +

Replies To: substitute drive letters with variables in XML to maintain docs saved

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2674
  • View blog
  • Posts: 11,292
  • Joined: 20-September 08

Re: substitute drive letters with variables in XML to maintain docs saved

Posted 21 June 2013 - 09:06 AM

Just some preliminary observations while i'm looking at your question in more detail:

Quote

public static final String USERHOMEDIR = System.getProperty("user.dir", ".");

That, to make sense, should be
public static final String USERHOMEDIR = System.getProperty("user.home");


You might like to look at

http://docs.oracle.c...tml#listRoots()

Update: yes, listRoots should do it for you. When i have this situation with indeterminate mount points (in your case drive letters) what i usually do is place an empty file with a unique name on the medium. It can then be easily searched for to determine what the mount point actually is.

This post has been edited by g00se: 21 June 2013 - 09:16 AM
Reason for edit:: Clarification

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1