1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| object destinationFile = System.AppDomain.CurrentDomain.BaseDirectory + @"nomdufichier.doc";
if (System.IO.File.Exists((string)destinationFile))
{
for (i = 2; System.IO.File.Exists((string)destinationFile); i++)
{
destinationFile = System.AppDomain.CurrentDomain.BaseDirectory + @"nomdufichier" + i + ".doc";
}
}
this.filename = (string)destinationFile;
FileStream fs = new FileStream(this.filename, FileMode.Create, FileAccess.Write);
StreamWriter sr = new StreamWriter(fs);
TextReader reader;
string modelFile = System.AppDomain.CurrentDomain.BaseDirectory + @"images\modelefichier.doc";
reader = new StreamReader(modelFile);
string line;
while (true)
{
line = reader.ReadLine();
if (line == null)
break;
else
// ici je remplace le texte si il doit être changé
entireText += line;
}
reader.Close();
sr.Close();
fs.Close();
StreamWriter sw = new StreamWriter(this.filename);
sw.Write(entireText);
sw.Close(); |
Partager