Is there a library like Apache Commons IO for .Net?
I am looking for the following functions:
- IOUtils.toByteArray(Stream);
- IOUtils.toString(Stream);
- FileUtils.write*();
- DirectoryWalker.
Is there a library like Apache Commons IO for .Net?
I am looking for the following functions:
functionality like that is A PART of .net. no need for a special library.
examples: http://www.xefteri.com/articles/show.cfm?id=8 http://aspnet.4guysfromrolla.com/articles/072303-1.aspx
There's not a direct port, AFAIK, but Apache Commons IO includes a whole bunch of stuff:
java.util.Comparator
for filesAre you after something specific?
Update: for e.g. the functionality of IOUtils.toByteArray(Stream) you can use the equivalent
Stream stream;
byte[] bytes;
using (BinaryReader br = new BinaryReader(stream)) {
bytes = br.ReadBytes(stream.Length);
}
and, of course, to get a string from the byte array, you simply need to decode it using the appropriate encoding:
String s = encoding.GetString(bytes)
where encoding is a System.Text.Encoding
instance, for example System.Text.UTF8Encoding
. I'm not sure of any libraries which provide the other functions you describe, but they're easy to write using TextWriter.WriteLine
, BinaryWriter.Write
, Directory.GetDirectories
and Directory.GetFiles
as in this example.