Hello.

I have a app designed to organize dir’s on on the C drive where it was created. XML is extensively used in the business logic and house cleaning etc.

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

<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.home", ".");

Now, this app is running from a jump drive. Its intended purpose is to run as a standalone app on a jump drive and organize dir’s on the same thumb drive.

Now, when My XML is written it is in a different pattern that looks like this :

<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.home", ".");

First, What is the definition or difference between C:\ and K:\ concerning the double or single backslashes?

Secondly, If I use the jump drive at another client machine it may again change the drive letter to another relative path.

<linkPath>
L:\\.targetGuide\admin_\admin\Note Folder\CREATED ON THUMB\index
</linkPath>

Now when I get to the next client machine it may write another drive letter. Obviously, Reading XML elements using previous drive letters will not be found and the app will fail.

What are my options?

Can a variable be used to generalize the drive letter when written to XML? Then when the XML is read it could be translated to equal : ?

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

<linkPath>
L:\\.targetGuide\admin_\admin\Note Folder\CREATED ON THUMB\index
</linkPath>

I am not really able to think this one through. Yet, I would ask if it was possible to force a consistent unique drive letter regardless of the client machine?

Recommended Answers

All 3 Replies

I'll try to enlight you a little bit.

First, we can not say you why the application is writing the double back slash before the point if you do not put here the code that produces those results.

Second, a drive letter probably can not be fixed unless you can fully administer on all the machines:
a) Hoy many phisical drives exist on the machine and the drive letters assigned to them
b) If the user can connect to a share using the net use on windows machines.
c) If the user can use the subst command on windows machines, to acces to a folder as if it was a drive
d) How USB (or firewire, or Sata) external drives will be mounted
e) The total number of mounted drives

Also have in mind that, on windows machines depending on the installed OS version, the free drives letter assignement goes from d to z while on others goes from z to d

Hope this helps you

Windows is the ONLY system (currently in common use) that uses backslashes for directory delimiters. It can also handle regular forward slash delimiters. The way any particular XML tool/library handles this is - well "indeterminate" comes to mind! Use forward slashes - which Windows can normally handle just fine, such as "C:/root/branch/node/file" instead of "C:\root\branch\node\file". If you do that, then your code should work also on non-windows systems!

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:\

[code]

1.  <linkPath>
2.  K:\\.targetGuide\admin_\admin\Note Folder\CREATED ON THUMB\index
3.  </linkPath>
4.  
5.  <linkPath>
6.  C:\Users\Steves\Documents\.targetGuide\admin_\admin\Note Folder\test\c drive test tab\index
7.  </linkPath>
8.  
9.  public static final String USERHOMEDIR = System.getProperty("user.dir", ".");

[/code] 

it would 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", ".");

[/code][code]

1.  <linkPath>
2.  K:\\.targetGuide\admin_\admin\Note Folder\CREATED ON THUMB\index
3.  </linkPath>
4.  
5.  <linkPath>
6.  C:\Users\Steves\Documents\.targetGuide\admin_\admin\Note Folder\test\c drive test tab\index
7.  </linkPath>
8.  
9.  public static final String USERHOMEDIR = System.getProperty("user.dir", ".");

[/code] 

Does this sound possible?
Thanks for the insight.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.