I want to create a file that is in specific directory.
For example: C:\x\y\z\aTextFile.txt
For this operation, I have to create the directory to create file.
Directory.CreateDirectory(@"C:\x\y\z\");
File.Create(@"C:\x\y\z\aTextFile.txt");
But I really wonder that I can do this operation in single line of code.
Any help and idea will be greately appreciated.
As far I know, there is no File creation method that create the directory at the same time in the .NET framework.
If the pattern “Directory check/creation, then file creation” is repeated a lot in your code, you have to implement it in a method.