예제 #1
0
 /// <summary>
 /// This method offers to augment indentation
 /// It keeps the number of indentation in a formatted string
 /// </summary>
 /// <param name="destination">formatted string data</param>
 public static void Indent(ref string destination)
 {
     try
     {
         string fileName;
         int    indent;
         bool   startLine;
         if (FinalFile.ExtractInfos(destination, out fileName, out indent, out startLine))
         {
             destination = "{\"" + fileName + "\"," + (indent + 1).ToString() + "," + startLine.ToString() + "}";
         }
     }
     catch { }
 }
예제 #2
0
 /// <summary>
 /// This method works with a formatted string data
 /// The first data is the full path of the file where to write
 /// The second data is the number of indentation
 /// The thirth data says true when starting a new line
 /// </summary>
 /// <param name="destination">formatted data information</param>
 /// <param name="text">text to write</param>
 /// <param name="enc">encoding object</param>
 public static void WriteToFile(ref string destination, string text, Encoding enc)
 {
     try
     {
         string fileName;
         int    indent;
         bool   startLine;
         if (FinalFile.ExtractInfos(destination, out fileName, out indent, out startLine))
         {
             FileStream   fs = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Write);
             StreamWriter sw = new StreamWriter(fs, enc);
             sw.Write(FinalFile.IndentText(text, indent, ref startLine));
             sw.Dispose();
             fs.Dispose();
             destination = "{\"" + fileName + "\"," + indent.ToString() + "," + startLine.ToString() + "}";
         }
     }
     catch { }
 }