I like it. I was going to suggest something similar, but more general. A “read” task that could read from various sources into a property. You could read a file, read a url, read an xpath, etc.

 

<read property=”foobar” type=”url” source=http://mywebsite/mywebservice.aspx />

 

<read property=”foobar” type=”file” source=”c:\myfolder\myfile.txt” />

 

Etc.

 


Gary McCullough 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Devin Grant
Sent: Thursday, September 16, 2004 2:47 PM
To: [EMAIL PROTECTED]
Subject: [Nant-users] FileFunctions Class

 

 

Can somebody please add a new function call “get-text” to the FileFunctions class?

 

Example:

[Function("get-text")]

public string GetText(string fileName)

{

  string text = "";

 

  if (File.Exists(fileName))

     text = GetTextFromFile(fileName);

 

  return text;

}

 

private static string GetTextFromFile(string fileName)

{

  string text = "";

 

  if (File.Exists(fileName))

     text = GetTextFromFile(new FileStream(fileName, FileMode.Open, FileAccess.Read));

 

  return text;

}

 

private static string GetTextFromFile(System.IO.Stream fileStream)

{

  string text = "";

 

  using(StreamReader reader = new StreamReader(fileStream))

  {

     text = reader.ReadToEnd();

  }

  fileStream.Close();

 

  return text; 

}

 

Devin Grant

Automation Tech Lead

TEL:  1-248-449-2135

FAX:  1-248-449-2021

[EMAIL PROTECTED]

autodesk®

 

Reply via email to