• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in directory creation for files

 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is there any way to create this directory without using the mkdir(); ...
I mean if i pass "D:\\try\\cool\\hot\\test.txt"
The directory try ,cool and hot can be automatically created ..


Thanks in advance
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you want to use mkdir ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that mkdirs can create a complete directory hierarchy in one step.
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have already written some logic so that the file can be created with the directory by using mkdir() ..But I want to know if there is any other API that can create the file and directory by passing the full path name and the file name.
Been googling it but didn't find any ..
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you already said in your first post that you were looking for something else, but you didn't say why. As long as we don't know why File.mkdir(s) doesn't meet your requirements, it's hard to give any advice.
 
Vihung Marathe
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what the original poster is trying to say is that they want one operation to make the directory and to create the file all in one go.

The answer is no. There is no method in the standard API that will both create the directories and create the file.

Nothing stopping you from creating your own method, though

Something like
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic