CSKernelFile.cFile.binaryWrite C# (CSharp) Method

binaryWrite() public method

public binaryWrite ( byte buffer ) : bool
buffer byte
return bool
        public bool binaryWrite(byte[] buffer)
        {
            if (!m_open) return false;
            try
            {
                m_bw.Write(buffer);
                return true;
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "binaryWrite", c_module, "failed writing in binary mode to file: " + m_path + Path.DirectorySeparatorChar + m_name);
                return false;
            }
        }

Usage Example

Example #1
0
        private String pGetFileImageInTMP(byte[] bytes)
        {
            String fileName = "~csrptImage";
            fileName = cUtil.getValidPath(System.IO.Path.GetTempPath()) + fileName;

            CSKernelFile.cFileEx fileEx = null;
            fileEx = new CSKernelFile.cFileEx();
            if (!fileEx.fileDelete(fileName)) { return ""; }

            CSKernelFile.cFile file = new CSKernelFile.cFile();
            if (!file.open(fileName, eFileMode.eBinaryWrite, true, true, eFileAccess.eLockWrite, false, false))
            {
                return "";
            }

            if (!file.binaryWrite(bytes))
            {
                return "";
            }

            file.close();

            return fileName;
        }