• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding the conversion of local machine path  RSS feed

 
Abhish Sharma
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friend ,
I am developing a program which reads some excel file from a remote computer and stores the path in UNC format. That is <machine name>\<shared folder name or say file path starting from shared folder>\<file name>.
I am storing the path in as local machine format right now. like wise c:\some_folder1\shared_folder\some_folder3\file.xls. But I need to store it as comp_name\shared_folder\some_folder3\file.xls. I know how to get all other, but How would i get to know the shared folder name and change my path acc. to my requirement. Yes this to note that I also retrived the name of all the shared folder through net share, but is not able to extract the name of local shared folder name. Can any one help me out in this???
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the current user has access to the share, you can just use java.io.File to work with the files. Just note that the file path must start with \\. When using that in a String you get \\\\. Alternatively, java.io.File is smart enough to convert any / into \ if needed, so you can also use only // (and then / to separate paths in the remainder of the path).
 
Abhish Sharma
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:If the current user has access to the share, you can just use java.io.File to work with the files. Just note that the file path must start with \\. When using that in a String you get \\\\. Alternatively, java.io.File is smart enough to convert any / into \ if needed, so you can also use only // (and then / to separate paths in the remainder of the path).



Thank you for replying sir, but i need the name of all the shared folder so that i change my file path acc. to requirement. So that if required i could later retrieve the file if required.
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With java.io.File you can't get all the shares, because the share is the lowest part that's still a directory; the server itself (\\server) isn't.

Perhaps JCIFS does not have this limitation, and you can use SmbFile and its listFiles methods to find the shares themselves. I haven't used JCIFS myself so I couldn't tell you.
 
Abhish Sharma
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:With java.io.File you can't get all the shares, because the share is the lowest part that's still a directory; the server itself (\\server) isn't.

Perhaps JCIFS does not have this limitation, and you can use SmbFile and its listFiles methods to find the shares themselves. I haven't used JCIFS myself so I couldn't tell you.



K. thanks for your concern
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!