0

尝试将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();
                     }
4

0 回答 0