Saves binary data to a file.

 

   
Syntax
 
     

[Visual Basic]
Sub Save(inFile As String, inData As Byte())

[C#]
void Save(string inFile, byte[] inData);

 

   
Params
 
     
Name   Description
inFile The path to the file to be saved
inData The data to be saved as an array of bytes

 

   
Notes
 
     

Use this function to save binary data into a file if for instance you want to save request data or uploaded files that are not text or image.

For example you might want to save out raw http request data into a file:

[Visual Basic]
Dim theLen As Integer = Request.InputStream.Length
Dim theData(theLen) As Byte
Request.InputStream.Read(theData, 0, theLen)
Dim myobj As New Gestalt
myobj.Save(Server.MapPath("raw.txt"), theData)

[C#]
int theLen = (int)Request.InputStream.Length;
byte[] theData = new byte [ theLen ];
Request.InputStream.Read(theData, 0, theLen);
Gestalt myobj = new Gestalt();
myobj.Save(Server.MapPath("raw.txt"), theData);

Or you might want to bypass the Canvas.SaveAs method so that you can modify the output data before it is saved:

[Visual Basic]
Dim gest As New Gestalt
Dim data() As Byte
Dim canvas As New Canvas
canvas.Color = Color.Red
canvas.Width = 100
canvas.Height = 100
Dim path As String = "pic.jpg"
data = canvas.GetAs(path, "Quality=normal")
gest.Save(Server.MapPath(path), data)

[C#]
Gestalt gest = new Gestalt();
Canvas canvas = new Canvas();
canvas.Color = Color.Red;
canvas.Width = 100;
canvas.Height = 100;
string path = "pic.jpg";
byte[] data = canvas.GetAs(path, "Quality=normal");
gest.Save(Server.MapPath(path), data);

 

   
See Also
 
     

Gestalt Read function. Canvas GetAs function.