Hello everyone.
I want to know how to press the Create file button, for example, (.txt) on C # (Windows Form).
Answer 1, Authority 100%
using system.io;
STRING PATH = "";
if (! file.xists (Path)) file.create (PATH);
p.s. In the same namespace there is a class of Directory for similar operations
transferred from the comment.
If you need to create a file with the text
- Check the existence of the file and if not, then create it
- If you want to write to a file – use Streamwriter
Sample code for writing text to file
string path = "";
STRING TEXT = "";
if (! file.xists (Path)) file.create (PATH);
Streamwriter Output = New Streamwriter (PATH);
Output.WriteLine (Text);
Output.Close ();
Answer 2
without problems))
system.io.file.writeAllText (Path, Text, [Encoding])