SharpCifs.Smb.SmbFile.IsWorkgroup0 C# (CSharp) Method

IsWorkgroup0() private method

private IsWorkgroup0 ( ) : bool
return bool
        internal virtual bool IsWorkgroup0()
        {
            if (Type == TypeWorkgroup || Url.GetHost().Length == 0)
            {
                Type = TypeWorkgroup;
                return true;
            }
            GetUncPath0();
            if (_share == null)
            {
                UniAddress addr = GetAddress();
                if (addr.GetAddress() is NbtAddress)
                {
                    int code = ((NbtAddress)addr.GetAddress()).GetNameType();
                    if (code == 0x1d || code == 0x1b)
                    {
                        Type = TypeWorkgroup;
                        return true;
                    }
                }
                Type = TypeServer;
            }
            return false;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Constructs an SmbFile representing a resource on an SMB network such
        /// as a file or directory.
        /// </summary>
        /// <remarks>
        /// Constructs an SmbFile representing a resource on an SMB network such
        /// as a file or directory. The second parameter is a relative path from
        /// the <code>context</code>. See the description above for examples of
        /// using the second <code>name</code> parameter. The <tt>shareAccess</tt>
        /// parameter controls what permissions other clients have when trying
        /// to access the same file while this instance is still open. This
        /// value is either <tt>FILE_NO_SHARE</tt> or any combination
        /// of <tt>FILE_SHARE_READ</tt>, <tt>FILE_SHARE_WRITE</tt>, and
        /// <tt>FILE_SHARE_DELETE</tt> logically OR'd together.
        /// </remarks>
        /// <param name="context">A base <code>SmbFile</code></param>
        /// <param name="name">A path string relative to the <code>context</code> file path</param>
        /// <param name="shareAccess">Specifies what access other clients have while this file is open.
        /// 	</param>
        /// <exception cref="System.UriFormatException">
        /// If the <code>context</code> and <code>name</code> parameters
        /// do not follow the prescribed syntax
        /// </exception>
        /// <exception cref="UnknownHostException"></exception>
        public SmbFile(SmbFile context, string name, int shareAccess)
            : this(context.IsWorkgroup0() ? new Uri("smb://" + name) : new Uri(
                          context.Url.AbsoluteUri + name), context.Auth)
        {
            if ((shareAccess & ~(FileShareRead | FileShareWrite | FileShareDelete)) !=
                0)
            {
                throw new RuntimeException("Illegal shareAccess parameter");
            }

            if (!context.IsWorkgroup0())
            {
                this.Addresses = context.Addresses;

                if (context._share != null || context.Tree != null)
                {
                    Tree = context.Tree;
                    _dfsReferral = context._dfsReferral;
                }
            }

            this._shareAccess = shareAccess;
            this._enableDfs = context.EnableDfs;
        }
All Usage Examples Of SharpCifs.Smb.SmbFile::IsWorkgroup0