Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.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/0/azure/12.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/cocoa/3.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
C# URL不是可识别的格式,我可以转换吗_C#_Azure - Fatal编程技术网

C# URL不是可识别的格式,我可以转换吗

C# URL不是可识别的格式,我可以转换吗,c#,azure,C#,Azure,我想在数据库表中显示存储为字符串的图像。当我运行代码时,我得到错误“无效URI,无法确定格式”。在表中,实际字符串如下所示:13d2dr09-377-423c-993e-22db3l390b66 如何将其转换为可识别的值 string sAdImageUrl = myReader.GetString(3); var image = new BitmapImage(); int BytesToRead

我想在数据库表中显示存储为字符串的图像。当我运行代码时,我得到错误“无效URI,无法确定格式”。在表中,实际字符串如下所示:13d2dr09-377-423c-993e-22db3l390b66

如何将其转换为可识别的值

                string sAdImageUrl = myReader.GetString(3);

                var image = new BitmapImage();
                int BytesToRead = 100;

                WebRequest request = WebRequest.Create(new Uri(sAdImageUrl,UriKind.Absolute));                   
                request.Timeout = -1;
                WebResponse response = request.GetResponse();
                Stream responseStream = response.GetResponseStream();
                BinaryReader reader = new BinaryReader(responseStream);
                MemoryStream memoryStream = new MemoryStream();

                byte[] bytebuffer = new byte[BytesToRead];
                int bytesRead = reader.Read(bytebuffer, 0, BytesToRead);

                while (bytesRead > 0)
                {
                    memoryStream.Write(bytebuffer, 0, bytesRead);
                    bytesRead = reader.Read(bytebuffer, 0, BytesToRead);
                }

                image.BeginInit();
                memoryStream.Seek(0, SeekOrigin.Begin);

                image.StreamSource = memoryStream;
                image.EndInit();

                imaPartners.Source = image;

            }
        }

好的,根据您的问题和另一个答案中的注释,听起来您有blob名称,但没有完整的URI。完整的blob uri将是

http(s)://<cloudstorageaccountname>.blob.core.windows.net/<containername>/<blobname>
以及输出:


好的,根据您的问题和另一个答案中的注释,听起来您有blob名称,但没有完整的URI。完整的blob uri将是

http(s)://<cloudstorageaccountname>.blob.core.windows.net/<containername>/<blobname>
以及输出:


13d2dr09-377-423c-993e-22db3l390b66不是uri。@数据库中的数据类型是二进制的吗?您需要将Uri存储为字符串。此拼图似乎缺少一些部分。那个字符串代表什么?它本身不是一个URI。是否应该将其附加到基本URI路径,并可能附加图像类型扩展?我建议您通过在浏览器的地址栏中键入示例来确定URI到底应该是什么。是的,它存储blob的名称,可以用类似的方式调用它吗?@user2631662您想实现什么?13d2dr09-377-423c-993e-22db3l390b66不是URI。@数据库中的数据类型是否为
binary
?您需要将Uri存储为字符串。此拼图似乎缺少一些部分。那个字符串代表什么?它本身不是一个URI。是否应该将其附加到基本URI路径,并可能附加图像类型扩展?我建议你通过在浏览器的地址栏中键入示例来了解URI的真正含义。是的,它存储blob的名称,可以用类似的方式调用它吗?@user2631662你想实现什么?谢谢,但我发现一个错误404未找到,它正在按照blob:https://******.blob.core.windows.net/image/0d3f5611-b97e-411a-8979-7a20afb77ea6hanks存储在表中,但我发现一个错误404未找到,它正在按照blob:https://******.blob.core.windows.net/image/0d3f5611-b97e-411a-8979-7a20afb77ea6存储在表中