Convert PHP pack() function to C#

B

Brian

Hi

PHP has a function called pack() (http://us2.php.net/pack). I need to
translate some code that uses this function to C#. What's the C#
equivalent of pack()?

Thanks, Brian

Example code using pack():

<?
/*/
security improved by by TRUI
www.trui.net

Originally posted at www.flashcomguru.com

//*/


//full path to dir with video.
$path = 'C:/.../clips/';


$seekat = $_GET["position"];
$filename = htmlspecialchars($_GET["file"]);
$ext=strrchr($filename, ".");
$file = $path . $filename;


if((file_exists($file)) && ($ext==".flv") && (strlen($filename)>2) &&
(!eregi(basename($_SERVER['PHP_SELF']), $filename)) &&
(ereg('^[^./][^/]*$', $filename)))
{
header("Content-Type: video/x-flv");
if($seekat != 0) {
print("FLV");
print(pack('C', 1 ));
print(pack('C', 1 ));
print(pack('N', 9 ));
print(pack('N', 9 ));
}
$fh = fopen($file, "rb");
fseek($fh, $seekat);
while (!feof($fh)) {
print (fread($fh, filesize($file)));
}
fclose($fh);
}
else
{
print("ERORR: The file does not exist"); }
?>
 
L

Lloyd Dupont

what about?
string.Format(format, arg1, arg2, arg3, ... arg17);

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
 
C

Chris R. Timmons

Hi

PHP has a function called pack() (http://us2.php.net/pack). I
need to translate some code that uses this function to C#.
What's the C# equivalent of pack()?

Brian,

I'm not aware of any equivalent to PHP's Pack function in .Net.

What problem are you trying to solve? Does it require something that
is 100% compatible with Pack? Or could a different way of packing
data into a binary data structure be used?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top