Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Environment.SpecialFolder在Xamarin/VisualStudio项目中指定特定文件?_C#_Xamarin_Streamwriter - Fatal编程技术网

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);