• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

How to create folder at runtime from client side in server in LAN Connection

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two computers connected in LAN lets say A and B, where A is server and B is client. I have created Java appln using that I want to create folder at A from B. In normal situation I used following code to create folder.



But this code does not work here. I tried to provide IP address in front of it.



But it gave me error.


The specified path, file is invalid.



Can you tell me guys how to create.
Thank you in advance.
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry guys I mistakenly created Post in different forum.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sanurag Dharme wrote:Sorry guys I mistakenly created Post in different forum.


No problem! I moved it to another (more appropriate) forum.
 
Sheriff
Posts: 22701
129
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
First of all, to access a folder on a remote folder using network shares, that folder must be actually shared. On Windows you often get that for free since all drives are shared out-of-the-box. Instead of D:, you need to use D$ (so replace the : with a $). If this doesn't work, you must create an explicit share.

That's not enough though. You also need to tell on which machine the share is located. This is done using \\machinename. In your case, the total path would become \\192.168.1.9\D$\ESM\Student. Next you need to escape all those backslashes if you need to create a string with that value. That indeed means the value will start with 4 backslashes in the code.

Note that you can also use forward slashes which you don't need to escape. I prefer those because it's clearer.
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still doesn't work.. I tried following code



and this also



and also this



but none this are working. Can you tell me whats wrong here.
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the solution. I map network drive of shared drive and pass its address and now its working.

 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sanurag Dharme wrote:I map network drive of shared drive and pass its address and now its working.


And what will happen if someone runs this code who has mapped the address to drive X (or didn't have mapped the drive at all)?
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh yes I didn't think of it, thanks for pointing out. But if these is not correct solution then can you tell me because previous didn't work out.
 
Rob Spoor
Sheriff
Posts: 22701
129
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
Did you have to provide credentials when you created the network mapping? If so then java.io.File won't be able to help you; it simply cannot handle shares that require you to login. You should check out JCIFS or a similar library instead.
 
Sanurag Dharme
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No don't need to provide credentials.
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic