Click here to Skip to main content
Sign Up to vote bad
good
See more: C#Text
hi,
 
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)
{
switch(number)
{
case 1:
string Text1 = "Hi im text1, this is currently doing";
break;
 
//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 - 20:18
Edited 15 Nov '12 - 20:31


3 solutions

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).
  Permalink  
Hi
 
This should help
 
http://msdn.microsoft.com/en-us/library/as2f1fez.aspx[^]
 
Jacques
  Permalink  
Comments
niko_tells - 16 Nov '12 - 3:13
And how to open this File? Cause File.Open doesnt really do something..
Jacques Loubser - 16 Nov '12 - 3:30
System.IO.StreamReader sr = new System.IO.StreamReader("TestFile.txt"); String line = sr.ReadToEnd(); //Do whatever with the output sr.Close();
niko_tells - 16 Nov '12 - 3:15
System.Diagnostics.Process.Start(Path);
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
 
[Link]
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 253
1 Rohan Leuva 220
2 Sergey Alexandrovich Kryukov 208
3 Abhinav S 168
4 Mahesh Bailwal 165
0 Sergey Alexandrovich Kryukov 8,494
1 OriginalGriff 6,799
2 CPallini 3,603
3 Rohan Leuva 2,923
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid