尝试在特定文件夹中保存txt文件时遇到问题,用户插入了txt文件的名称,创建的目录没有任何问题,但txt文件未保存,我只能访问我不使用文件夹时保存文本文件(这不是我想要的),对此有什么想法?任何帮助将不胜感激。
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
string directory = "data";
if (!myIsolatedStorage.DirectoryExists(directory))
{
myIsolatedStorage.CreateDirectory(directory); //create the folder where the data will be placed
}
string name = textbox1.Text;
using (StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream(directory+"\\"+name+".txt", FileMode.Create, FileAccess.Write, myIsolatedStorage)))
{
int total_number_of_points=(App.Current as App).number_of_random_points + (App.Current as App).number_of_foresight_points;
writeFile.WriteLine("Point East North Height STD-E STD-N STD-H Longitude Latitude Description");
for (int n = 1; n <= total_number_of_points; n++)
{
string point_data = "";
for (int i = 0; i < 8; i++)
{
point_data = point_data + " " + Convert.ToString((App.Current as App).point_information[n, i]);
}
point_data = point_data + " " + Convert.ToString((App.Current as App).point_description[n]);
writeFile.WriteLine(" " + Convert.ToString(n) + " " + point_data);
}
writeFile.Close();
}