C# 如何使用Environment.SpecialFolder在Xamarin/VisualStudio项目中指定特定文件?
我试图将文本附加到文本文件中,但我找不到任何地方如何实际定位现有文件C# 如何使用Environment.SpecialFolder在Xamarin/VisualStudio项目中指定特定文件?,c#,xamarin,streamwriter,C#,Xamarin,Streamwriter,我试图将文本附加到文本文件中,但我找不到任何地方如何实际定位现有文件 partial void MainBtn_TouchUpInside(UIButton sender) { var Pp = ("Selected Form Of Exchange: Paypal"); string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocumen
partial void MainBtn_TouchUpInside(UIButton sender)
{
var Pp = ("Selected Form Of Exchange: Paypal");
string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments(WHAT DO I WRITE IN THIS SPACE??);
using (StreamWriter outputFile = new **StreamWriter(Path.Combine(mydocpath, "SelectPayment.txt")))
//我知道文件已经存在,我只是在尝试不同的事情
{
outputFile.WriteLine(Pp);
}
那我该怎么办?谢谢
Josh通过组合文件夹路径和文件名来创建文件路径,从而指定文件
// this returns the path to a folder
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
// combine that with a file name to create a file path
string file = Path.Combine(path, "myFile.text");
// append text to file
File.AppendAllText(file, "this is the text I want to append);