创建目录并生成文本

 1 public void CreateTxt(Vector3d[] Points)
 2         {
 3             if (Points.Length == 0) return;
 4             string dirname = Path.Combine(WorldSettings.StartupDirectory, @"TempPoints");
 5             DirectoryInfo dir = new DirectoryInfo(dirname);
 6             if (!dir.Exists)
 7             {
 8                 dir.Create();
 9             }
10             string dircoor = dirname + @"\Points.txt";
11             string tex = string.Empty;
12             for (int i = 0; i < Points.Length; i++)
13             {
14                 tex += Points[i].X.ToString() + ",";
15                 tex += Points[i].Y.ToString() + ",";
16                 tex += Points[i].Z.ToString() + ",";
17                 //tex += "\r\n";
18             }
19             System.IO.File.WriteAllText(dircoor, tex);
20             MessageBox.Show("Points.txt创建成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
21 
22         }

 

posted @ 2013-09-17 14:57  寻梦放歌  阅读(333)  评论(0编辑  收藏  举报