Ejemplo n.º 1
0
        private static int CompressStream(ref CompressionParameters parameters, ISequentialStream input, ISequentialStream output)
        {
            if (IntPtr.Size == 4)
            {
                return(CompressStream86(ref parameters, input, output));
            }

            return(CompressStream64(ref parameters, input, output));
        }
Ejemplo n.º 2
0
 private static extern int CompressStream64(ref CompressionParameters parameters, ISequentialStream input, ISequentialStream output);
Ejemplo n.º 3
0
 public void SetBLOBFromStream(Int32 hRow, Int32 hCol, ISequentialStream pIStream)
 {
     _innerObject.SetBLOBFromStream(hRow, hCol, pIStream);
 }
Ejemplo n.º 4
0
 public void SetFromStream(ISequentialStream pISequentialStream)
 {
     _innerObject.SetFromStream(pISequentialStream);
 }
        /// <summary>
        /// The XMLHttp control only gives back a file stream to save; this method
        /// save out that stream to disk, without all of the cross-domain restrictions
        /// of that provided by the ADO object's.
        /// </summary>
        public bool SaveFileStream(object fileStream, string localFilePath)
        {
            byte []              data;
            System.UInt32        bytesAvailable = 4096, bytesRead = 0;
            System.IO.FileStream writeStream = null;
            ISequentialStream    readStream  = null;

            try
            {
                if (System.IO.File.Exists(localFilePath))
                {
                    // If this throws an exception (due to permissons or file sharing),
                    // we catch and return false.
                    System.IO.File.Delete(localFilePath);
                }

                writeStream = System.IO.File.Create(localFilePath);
                readStream  = (ISequentialStream)fileStream;

                data = new byte[bytesAvailable];

                // ISequentialStream implementors are requested -- but not required --
                // to return S_OK and nRead == 0 on end-of-stream. Therefore, we
                // ignore the return value from .Read (since it's basically meaningless)
                // and simply check the value returned from the call. If it comes back
                // zero, we either reached the end of the stream or the caller errored
                // out and we didn't do anything.
                bytesRead = 0;
                readStream.Read(data, bytesAvailable, out bytesRead);
                while (bytesRead > 0)
                {
                    writeStream.Write(data, 0, (int)bytesRead);

                    bytesRead = 0;
                    readStream.Read(data, bytesAvailable, out bytesRead);
                }

                writeStream.Close();
            }
            catch (System.Exception)
            {
                if (writeStream != null)
                {
                    writeStream.Close();

                    // Since the file started to be created, attempt to clean up
                    // after the garbage that may have been left around if the
                    // handed-in stream generated an exception.
                    if (System.IO.File.Exists(localFilePath))
                    {
                        try
                        {
                            System.IO.File.Delete(localFilePath);
                        }
                        catch (System.Exception)
                        {
                        }
                    }
                }

                return(false);
            }

            return(true);
        }