如何使用 Environment.SpecialFolder 在我的 Xamarin/VisualStudio 项目中指定特定文件?
How do I specify a specific file in my Xamarin/VisualStudio Project using Environment.SpecialFolder?
我正在尝试将文本附加到文本文件,但我无法在任何地方找到如何实际定位现有文件。
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);
}
那我该怎么办?谢谢
乔什
您通过组合文件夹路径和文件名来创建文件路径来指定文件
// 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);
我正在尝试将文本附加到文本文件,但我无法在任何地方找到如何实际定位现有文件。
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);
}
那我该怎么办?谢谢 乔什
您通过组合文件夹路径和文件名来创建文件路径来指定文件
// 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);