user1156718
user1156718

Reputation: 69

File class cannot access file using absolute path

I am trying to access a file using the file class but it works only with below code

File file = new File("s:\\testing\\selenium\\Version8\\locators\\OR.properties");

however I need to use this approach where I go directly to the server: "\\GIGABYTE\\s-drive\\Testing\\selenium\\Version8\\locators\OR.properties"in which the above will not find the file - very strange

Any clue as to why this is?

Upvotes: 0

Views: 57

Answers (2)

ManojP
ManojP

Reputation: 6248

You can try the below code:

File file = new File("\\\\GIGABYTE\\s-drive\\Testing\\selenium\\Version8\\locators\\OR.properties");

or this:

File file = new File("//GIGABYTE/s-drive/Testing/selenium/Version8/locators/OR.properties");

Upvotes: 0

James Fox
James Fox

Reputation: 691

To go directly to the server you will need to have 4 slashes as two are actual slashes and 2 are escape characters:

\\\\GIGABYTE\\s-drive\\Testing\\selenium\\Version8\\locators\OR.properties

Upvotes: 1

Related Questions