public void SetFileName(string directory, string file)
 {
     this.AssertInternalLobIsValid();
     if (!this.IsNull)
     {
         this._lob.AssertConnectionIsOpen();
         this._lob.AssertTransactionExists();
         OciFileDescriptor filep = (OciFileDescriptor) this.LobLocator.Descriptor;
         if (filep != null)
         {
             this.LobLocator.ForceClose();
             int rc = TracedNativeMethods.OCILobFileSetName(this.Connection.EnvironmentHandle, this.ErrorHandle, filep, directory, file);
             if (rc != 0)
             {
                 this.Connection.CheckError(this.ErrorHandle, rc);
             }
             this.LobLocator.ForceOpen();
             this._fileName = null;
             this._directoryAlias = null;
             try
             {
                 this._lob.Position = 0L;
             }
             catch (Exception exception)
             {
                 if (!System.Data.Common.ADP.IsCatchableExceptionType(exception))
                 {
                     throw;
                 }
             }
         }
     }
 }
Example #2
0
        /// <include file='doc\OracleBFile.uex' path='docs/doc[@for="OracleBFile.SetFileName"]/*' />
        public void SetFileName(
            string directory,
            string file
            )
        {
            AssertInternalLobIsValid();

            if (!IsNull)
            {
                _lob.AssertConnectionIsOpen();
                _lob.AssertTransactionExists();

                LobLocator.ForceClose();                         // MDAC 86200: must be closed or the ForceOpen below will leak opens...

                IntPtr newHandle = (IntPtr)LobLocator.Handle;

                int rc = TracedNativeMethods.OCILobFileSetName(
                    Connection.EnvironmentHandle,
                    ErrorHandle,
                    ref newHandle,
                    directory,
                    (short)directory.Length,
                    file,
                    (short)file.Length
                    );

                if (0 != rc)
                {
                    Connection.CheckError(ErrorHandle, rc);
                }

                LobLocator.ForceOpen();                                                                        // SetFileName automatically closes the BFILE on the server, we reopen it

                Debug.Assert((IntPtr)LobLocator.Handle == newHandle, "OCILobFileSetName changed the handle!"); // Should never happen...
                Descriptor.SetOciHandle(newHandle);                                                            // ...but just in case.

                _fileName       = null;
                _directoryAlias = null;
                _lob.Position   = 0;
            }
        }