public void WriteToFile(string title, bool enable_console_output, bool overwrite, bool using_full_path) { string path = Paths.DistributionRepo + "\\" + title + ".dist"; if (using_full_path) { path = title; } if (File.Exists(path) && !overwrite) { throw new Exception("File exists, overwriting permission not explicitly granted"); } DateTime then = DateTime.Now; string[] contents = new string[x_node_count * y_node_count + additional_file_lines]; contents[0] = bounds.ToString() + ":max_value:" + maxval.ToString() + ":min_value:" + minval.ToString(); contents[1] = "Nx:" + x_node_count.ToString() + ":Ny:" + y_node_count.ToString(); for (int i = 0; i < x_node_count; i++) { for (int j = 0; j < y_node_count; j++) { contents[additional_file_lines + i + x_node_count * j] = nodes[i, j].ToString(); } } File.WriteAllLines(path, contents); DateTime now = DateTime.Now; if (enable_console_output) { Console.WriteLine("File output in " + (now - then).Milliseconds.ToString() + " milliseconds."); } }
public void WriteFile(string title, bool using_full_path, bool allow_overwrite) { string path = bc_repo + "\\" + title + ".bc"; if (using_full_path) { path = title; } if (File.Exists(path) && !allow_overwrite) { throw new Exception("Error: Overwriting permissions not granted."); } List <string> stuff = new List <string>(); stuff.Add(bounds.ToString()); stuff.Add(string.Format("Nx:{0}:Ny:{1}", xcount, ycount)); string px = "positive_x:" + ConditionTypeToString(positive_x); stuff.Add(px); int px_count = positive_x_vals.Length; for (int i = 0; i < px_count; i++) { stuff.Add(positive_x_vals[i].ToString()); } string nx = "negative_x:" + ConditionTypeToString(negative_x); stuff.Add(nx); int nx_count = negative_x_vals.Length; for (int i = 0; i < nx_count; i++) { stuff.Add(negative_x_vals[i].ToString()); } string py = "positive_y:" + ConditionTypeToString(positive_y); stuff.Add(py); int py_count = positive_y_vals.Length; for (int i = 0; i < py_count; i++) { stuff.Add(positive_y_vals[i].ToString()); } string ny = "negative_y:" + ConditionTypeToString(negative_y); stuff.Add(ny); int ny_count = negative_y_vals.Length; for (int i = 0; i < ny_count; i++) { stuff.Add(negative_y_vals[i].ToString()); } File.WriteAllLines(path, stuff.ToArray()); }