1,105,625 Community Members

Create CON folder through JAVA

Member Avatar
abctoz
Newbie Poster
5 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi All,
I have created a CON, PRN folder(http://www.hoax-slayer.com/con-folder-name.shtml) using "md\\.\\c:\con " through DOS prompt, i was trying to create same CON and PRN folder through Java code using
"Runtime.getRuntime().exec("md\\\\.\\d:\\con");"

But it is giving following Exception :

Cannot run program "md\\.\d:\con": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source)"

Please guide me how to make the CON folder through JAVA code.

Thanks in advance.

Member Avatar
peter_budo
Code tags enforcer
7,939 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
0
 

Any good reason to mess around with Runtime when you do the same with mkdir() method of File class?

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

And for general information read this article thoroughly. You are falling into the "not a command" trap.

But Peter is correct, you should not be using Runtime for this, at all.

Member Avatar
abctoz
Newbie Poster
5 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Any good reason to mess around with Runtime when you do the same with mkdir() method of File class?

I want to create a CON name folder, which is normally not possible with mkdir(); (As this is OS reserved Word) that's why i tried it out with "Runtime.getRuntime().exec("mkdir c:\con\\");" because DOS prompt allows us to create CON folder with "mkdir c:\con\".

Member Avatar
peter_budo
Code tags enforcer
7,939 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
0
 

Just give us one good reason why it MUST BE called con and not something else?

Member Avatar
abctoz
Newbie Poster
5 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Just give us one good reason why it MUST BE called con and not something else?

Hi.. i want to create a folder which can not be rename and delete.. by any user(even admin).CON,PRN,NUL,AUX.. etc are some of Folder's name which OS has reserved(which restrict rename and deletion).. so just to put restriction over my folder i want to use con name for my folder

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

:sigh:

And have you read that article, yet?

P.S. that reasoning, as well as that command, will work just oh so well on unix platforms, as well, huh?

Member Avatar
abctoz
Newbie Poster
5 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

:sigh:

And have you read that article, yet?

P.S. that reasoning, as well as that command, will work just oh so well on unix platforms, as well, huh?

Hi,
Thanks for reply.
Yes i had gone through the article link, which you had provided.
I had tried the way explained in the article, but still facing the same problem
Firstly i want to make it work with windows.. as these CON,PRN are WINDOWS reserved word, it is not working in windows..

Member Avatar
masijade
Industrious Poster
4,165 posts since Feb 2006
Reputation Points: 1,351 [?]
Q&As Helped to Solve: 510 [?]
Skill Endorsements: 22 [?]
Team Colleague
Featured
 
0
 

In what way is that? Post that code explain, exactly, what "didn't work" means.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article