CSKernelFile.cFile.close C# (CSharp) Method

close() public method

public close ( ) : void
return void
        public void close()
        {
            try
            {
                if (m_file != null)
                {
                    m_file.Close();
                    if (m_br != null)
                    {
                        m_br.Close();
                        m_br = null;
                    }
                    if (m_bw != null)
                    {
                        m_bw.Close();
                        m_bw = null;
                    }
                    m_file = null;
                }
                m_open = false;
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "binaryRead", c_module, "failed reading in binary mode from file: " + m_path + Path.DirectorySeparatorChar + m_name);
            }
        }

Usage Example

Example #1
0
        private bool resumeDBAccessMissing(String connectString, bool saveInReport, CSDataBase.cDataBase cn)
        { // TODO: Use of ByRef founded Private Function ResumeDBAccessMissing(ByVal StrConnect As String, ByVal SaveInReport As Boolean, ByRef cn As cDataBase) As Boolean
            try
            {
                // if the database is not access we do nothing
                //
                if (connectString.ToLower().IndexOf("PROVIDER=Microsoft.Jet.OLEDB.4.0;".ToLower()) == 0)
                {
                    return false;
                }

                // get the datasource's name
                //
                String fileName = "";
                fileName = cUtil.getToken(connectString, "Data Source");

                // ask to the user if he wan to search for the database file
                //
                CommonDialog commDialog = null;
                if (FindAccessFile != null)
                {
                    FindAccessFileEventArgs e = new FindAccessFileEventArgs(fileName);
                    FindAccessFile(this, e);
                    if (e.cancel)
                    {
                        return false;
                    }
                    commDialog = e.commonDialog;
                }

                CSKernelFile.cFile file = new CSKernelFile.cFile();

                file.filter = "Access files|*.mdb";
                file.init("ResumeDBAccessMissing", C_MODULE, commDialog);

                if (!file.open(m_pathDefault + Path.DirectorySeparatorChar + file,
                                CSKernelClient.eFileMode.eRead,
                                false,
                                false,
                                eFileAccess.eShared,
                                true,
                                true))
                {
                    return false;
                }

                fileName = file.fullName;

                file.close();

                connectString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName;

                if (!cn.initDb(connectString))
                {
                    return false;
                }

                // save the new location 
                //
                if (saveInReport)
                {
                    m_connect.setStrConnect(connectString);
                }
                return true;

            }
            catch (Exception ex)
            {
                cError.mngError(ex, "ResumeDBAccessMissing", C_MODULE, "");
                return false;
            }
        }
All Usage Examples Of CSKernelFile.cFile::close