Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my application I have to create files programatically,
How I can do that?
If you know, then please help me.
Posted
Updated 7-Feb-11 23:06pm
v3
Comments
MCY 8-Feb-11 8:27am    
what type of file you have in mind? text, image, pdf, they all have different algorithms and methods.

1 solution

It depends on what type of file you need to create.
The following creates a text file, which is about as basic as you can get:
C#
List<string> lines = new List<string>();
lines.Add("Hello");
lines.Add("A line of text");
lines.Add("More text");
lines.Add("Yet more text");
lines.Add("Last line");
File.WriteAllLines(@"F:\Temp\textfile.txt", lines.ToArray());
 
Share this answer
 
Comments
honey4bee 8-Feb-11 4:50am    
that is depend on extension the related files will be created.
how?
OriginalGriff 8-Feb-11 4:58am    
I'm afraid you are going to have to ask that again.
It doesn't make any sense as you have worded it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900