Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > C# (си шарп)
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 22.08.2012, 21:03   #1
boriskaaa
Новичок
Джуниор
 
Регистрация: 22.08.2012
Сообщений: 1
По умолчанию Создание квоты

Всем привет.

Мне нужно создать квоту на каталог. Использую fsrm

На локальной тачке квота создаётся. А если мне надо на удалённом сервере это сделать.

Как мне это реализовать на windows server 2008 r2 ?

В данный момент у меня работает такой вот код.

Код:
public void setQoutaFolder(string patch)
        {

            // Here comes the code that goes into your main class or wherever you need it.

            // Directory to Set/Change the quota of
            string directory = @"C:\"+patch;

            // If you want to create the directory if it doesn't exist uncomment this section
            /*
            if (!Directory.Exists(directory))
            {
              Directory.CreateDirectory(directory);
            }
            */

            // I want 512MB quota,  you can replace this with what you want. The quota size is in KB.
            int NewQuotaSize = 2000 * 1024 * 1024;

            // Create our interface
            IFsrmQuotaManager FSRMQuotaManager = new FsrmQuotaManagerClass();

            IFsrmQuota Quota = null;

            try
            {
                // First we need to see if there is already a quota on the directory.
                Quota = FSRMQuotaManager.GetQuota(directory);
                // If there is quota then we just set it to our new size
                Quota.QuotaLimit = NewQuotaSize;
            }
            catch (COMException e)
            {
                unchecked
                {
                    if (e.ErrorCode == (int)0x80045301)
                    {
                        // There is no quota on this directory so we need to create it.
                        Quota = FSRMQuotaManager.CreateQuota(directory);
                        // And then set our desired quota
                        Quota.QuotaLimit = NewQuotaSize;
                    }
                    else
                    {
                        // some other COM exception occured so we return the error
    
                    }
                }
            }
            catch (Exception e)
            {
                // Generic error handling would go here

            }

            // and finally we commit our changes.
            Quota.Commit();
        }
boriskaaa вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Создание внутреннего и внешнего серверов. Создание серверов автоматизации. Ann_Sh Помощь студентам 3 09.10.2011 15:53
Создание БД Mythbuster Microsoft Office Access 1 11.01.2011 14:43