1
.NET Framework / Re: Easy read/write file [.NET]
« on: April 02, 2011, 03:02:40 am »
I'd strongly recommend using the methods under the System.IO namespace instead of using old VB references.
It's as simple as:
File.WriteAllBytes(path, data)
File.WriteAllText(path, stringData)
byte[] data = File.ReadAllBytes(path); //C#
Dim data as Byte() = File.ReadAllBytes(path) 'VB
string stringData = File.ReadAllText(path) //C#
Dim stringData as String = File.ReadAllText(path) 'VB
It's as simple as:
File.WriteAllBytes(path, data)
File.WriteAllText(path, stringData)
byte[] data = File.ReadAllBytes(path); //C#
Dim data as Byte() = File.ReadAllBytes(path) 'VB
string stringData = File.ReadAllText(path) //C#
Dim stringData as String = File.ReadAllText(path) 'VB