C#将文本文件写入exe文件夹 [英] C# Write Textfile into exe Folder

查看:109
本文介绍了C#将文本文件写入exe文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在程序中有一段历史,记录了程序的内容
目前正在执行.

现在,我想在首次运行时创建一个文本文件,将其写入exe文件夹以写入
每次将此文档放入此文件中.

我正在使用一个类将文档编写到富文本框中.
执行本文档的类的方法如下所示:



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
}
}



所以我的问题是:

-在exe文件夹中创建文本文件
求助:(-一般写入此现有文件,不要覆盖)
求助:(-打开此现有文本文件进行查看)


谢谢

ps .:如果您需要更多说明,请告诉我

问候Niko



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

推荐答案

如果您只是想写到现有文件的末尾,这应该会有所帮助,则需要使用streamreader和streamwriter中streamwrite中的参数之一让您指定要保存文件的位置

[链接 ]
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]


请勿写入程序文件夹!请使用"ProgramData"文件夹.您可以通过Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)获取它.为您的公司和您的程序创建子文件夹.
如果应该按用户记录日志,则可以在Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)中使用相同的结构.
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).


您好
这应该有帮助

http://msdn.microsoft.com/en-us/library/as2f1fez.aspx [ ^ ]

雅克
Hi
This should help

http://msdn.microsoft.com/en-us/library/as2f1fez.aspx[^]

Jacques


这篇关于C#将文本文件写入exe文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆