Write Binary data to file ASP.net
internal static bool WriteFileVirtually(string filePathWithName, byte[] data)
{
try
{
BinaryWriter writer = null;
string name = filePathWithName;
FileStream write = File.OpenWrite(name);
writer = new BinaryWriter(write);
writer.Write(data);
writer.Flush();
write.Dispose();
write.Close();
writer.Close();
return true;
}
catch (Exception ex) { return false; }
}
{
try
{
BinaryWriter writer = null;
string name = filePathWithName;
FileStream write = File.OpenWrite(name);
writer = new BinaryWriter(write);
writer.Write(data);
writer.Flush();
write.Dispose();
write.Close();
writer.Close();
return true;
}
catch (Exception ex) { return false; }
}
Comments
Post a Comment