Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自MySQL C#/PHP的流文件_C#_Php_Mysql - Fatal编程技术网

来自MySQL C#/PHP的流文件

来自MySQL C#/PHP的流文件,c#,php,mysql,C#,Php,Mysql,我正在开发一个客户端应用程序,在这个应用程序中,我的用户根据PHP制作的web API进行身份验证。当我的用户通过身份验证后,我想从MyBB数据库中传输一个blob,这样我就可以在客户端上使用Assembly.Load并运行.exe文件 这就是我努力实现这一目标的方式。 这是我在服务器上的API global $db, $encryptionEngine; if (isset($_GET['file']) && isset($_GET['username'])) { $

我正在开发一个客户端应用程序,在这个应用程序中,我的用户根据PHP制作的web API进行身份验证。当我的用户通过身份验证后,我想从MyBB数据库中传输一个blob,这样我就可以在客户端上使用Assembly.Load并运行.exe文件

这就是我努力实现这一目标的方式。 这是我在服务器上的API

global $db, $encryptionEngine;
if (isset($_GET['file']) && isset($_GET['username'])) 
{
    $username = $encryptionEngine->init($_GET['username'],"decrypt");
    $query = $db->simple_select("users", "*", "LOWER(username)='".$db->escape_string(my_strtolower($username))."'", array('limit' => 1));
    $user = $db->fetch_array($query);

    if ($user['usergroup'] == 3 || $user['usergroup'] == 4 || $user['usergroup'] == 6 || $user['usergroup'] == 8 || $user['usergroup'] == 9)
    {

        $filename = $encryptionEngine->init($_GET['file'],"decrypt");
        $query = $db->simple_select("files", "filecontent", "LOWER(filename)='".$db->escape_string(my_strtolower($filename))."'", array('limit' => 1));
        $file = $db->fetch_array($query);
        return $file['filecontent'];
    }
}
MySQL数据库上的filecontent是Byte[]或VarBinary。 这就是我如何尝试在我的客户机(C#)中对文件进行流式处理的方法

然而,当我使用webClient.DownloadData时,它将以字节[]的形式下载整个页面,但我如何才能访问VarBinary/byte[]

        public byte[] StreamFile(string file, string username)
    {
        using (WebClient webClient = new WebClient())
        {
            string address = Conversions.ToString(_authUrl + "?action=streamFile&file=" + _encryption.Encrypt(file) +"&username="+_encryption.Encrypt(username));
            byte[] str = webClient.DownloadData(address);
            return str;
        }
    }