Hi?
View Complete Post
Hi All,
Is it possible to convert the Report Document object as a byte array and store it in SQL , later retrieve and assing it to a report ?
Hi guys,
I am trying to read in a binary file created by a legacy VBA application.
One of the sections of the file is a date, which was written out as a four byte segment equivalent a VBA long with value 40451.
In the binary array this is represented as: 33, 67, 101, 135
If I convert the binary array back into a long in VBA I get the number 40451 again.
However, if I create a four byte array in C# and try and convert that to an Int32 using BitConverter I get the value -2023406815.
I have tried reversing the byte order but not getting anything close to 40451.
Anyone got any ideas on how to get the same value as the original VBA long?
Thanks,
Wilson.
Hi Everyone-
I'm retrieving a binary file from the database, a .pdf file that I would like to let the user open and view. From what I can tell, there are two steps to do this:
1. Convert binary file to byte array
2. Convert byte array to file content
Here's what I've got so far:
Dim c1 = (From c In dc.Documents _
Where c.userID = userGuid _
Select New With {c.downloadName, _
c.docData, _
c.type, _
c.length}).FirstOrDefault()
Dim bArray As Byte() = CType(c1.docData("binary"), Byte())
If bArray.Length > 0 Then
Dim fs As System.IO.FileStream = New System.IO.FileStream("d:\xx.pdf", IO.FileMode.Create)
fs.Write(bArray, 0, bArray.Length)
fs.Close()
End If
This isn't working and I'm having a heck of a time trying to find a solution. I'm getting a blue squiggly under c1.docData in the Dim bArray line.
What am I doing wrong?
Edited by Nancy Michell
MSDN Magazine May 2004
how to convert byte array to memory stream in vb.net.
Hi,
I am using the below function to cast the byte array to the structure.But when i do that i am getting an exception saying"Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Please
help me on this ASAP.
public VasConfig BytetoStructure(byte[] bff)
{
GCHandle pinnedPacket = GCHandle.Alloc(bff, GCHandleType.Pinned);
VasConfig vasconfig = (VasConfig)Marshal.PtrToStructure(
pinnedPacket.AddrOfPinnedObject(),
typeof(VasConfig));
pinnedPacket.Free();
return vasconfig;
}
//**************************************
Structure is as below
//**************************************
#region Vas Data Structure
//Vas Commands used for communication between PC client to DSP server
using System.Runtime.InteropServices;
public enum VasCommands
{
GET_VAS_CONFIG = 10,
SET_VAS_CONFIG,
GET_VIDEO,
DATA,
}
//This is used for identifying the first data buffer
public enum yuv_fmt
{
Y = 5,
U,
V
}
//Video formats
//Video formats
public enum VideoFormat
{
YUV_420 = 15,
YUV_422,
RGB,
NEW_FMT,
}
//Data stream types: Currently only video is supported
public enum DataTypes
{
VIDEO = 1,
AUDIO,
TEXT,
}
//Error Code definitions
public enum ERROR_CODE
{
ERROR_MEMORY_ALLOC,
ERROR_APPLICATION,
ERROR_RESERVED;
}
I am getting the video in chunks of bytes. When i get all the bytes, then i write them to a file and give a a source to media element and that works fine.
But what i want is that I don't have to wait for all the bytes and i can start showing the video as soon as i receive the first chunk of bytes and then the video should continue as i get the secong chunk of bytes and so on. So the video should keep on streaming and appear as live.
Can someone help me out here?
Cheers,
Sumit
I have a WCF service hosted in IIS that takes a byte array. If I send a small byte array the service works, if I send a large (282, 624) byte array the service fails.
I have tried increasing values etc in the config files and nothing seems to work. Any help would be greatly appreciated. Thanks
The config files are as follows:
Client:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="GetDataFromServer" value="False"/>
<add key="UseWpfService" value="True" />
</appSettings>
<connectionStrings>
<add name="ServerEntities" connectionString="metadata=res://*/Server.csdl|res://*/Server.ssdl|res://*/Server.msl;provider=System.Data.SqlClient;provider connection string="Data Source=XPS1;Initial Catalog=TestServer;Integrated
Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
&
I have an asp.net website and am exporting an image from the Report Viewer. I have created my byte array to get the data from the report viewer and now I need to save an image with transparency to the client machine using the response headers. I was able to do this by saving the array to the server as a bmp and then adding transparency and saving to the client as a GIF; however, the requirement has changed and now I need to do this without saving the file to the server and even though I have found several solutions using unsafe code these will not work for us because we are not allowed to use unsafe code in our environment.
So in short I need a way to go from an array of bytes to a transparent gif and save to the client machine without using unsafe code and without saving a file to the server.
Hall of Fame Twitter Terms of Service Privacy Policy Contact Us Archives Tell A Friend