Click here to Skip to main content
13,294,840 members (63,010 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i have a sort of history in my programm wich, documents what the programm
is currently doing.

Now i want to create a textfile on first run, into the exe folder to write
this documentation every time into this file.

I am using a class for writing the documentation into a rich textbox.
the method of the class wich perform this documentation is looking like this:

public void Aktual(int number)
case 1:
string Text1 = "Hi im text1, this is currently doing";
//And further

so my problems are:

- Creating a textfile into exe folder
SOLVED: (- Write in general into this existing file, to dont overwrite)
SOLVED: (- Open this existing textfile to view it)

Thank you

ps.: Let me know if you need more explanation

greets Niko
Posted 15-Nov-12 21:18pm
Updated 15-Nov-12 21:31pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

if your just trying to write to the end of your existing file this should help, you need to use streamreader and streamwriter one of the parameters in the streamwrite lets you specify where you want to save the file

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Do not write into the program folder! Use the "ProgramData" folder instead. You can get it via Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData). Create subfolders for your company, and for your program.
If logging should be per user, you can use the same structure in Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

niko_tells 16-Nov-12 3:13am
And how to open this File? Cause File.Open doesnt really do something..
Jacques Loubser 16-Nov-12 3:30am
System.IO.StreamReader sr = new System.IO.StreamReader("TestFile.txt");
String line = sr.ReadToEnd();
//Do whatever with the output
niko_tells 16-Nov-12 3:15am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100