• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding the conversion of local machine path

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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???
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic