none
在修改Site Collection的Quota时如何检查Content DB是否有足够的空间? RRS feed

  • 问题

  • 能否通过以下方法取得ContentDB的剩余空间, 然后再与Quota中增加的空间比较?

    using (SPSite site = new SPSite("site url"))
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandText = "sp_spaceused";   
                    cmd.CommandType = CommandType.StoredProcedure;    
                    SqlConnection sqlConnection = new SqlConnection(site.ContentDatabase.DatabaseConnectionString);
                    sqlConnection.Open();
                    cmd.Connection = sqlConnection;

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            string unallocated = reader.GetString(2); // unallocated space
                        }
                    }
                }

    2010年5月12日 9:44

全部回复