コード例 #1
0
        /// <summary>
        /// Use to method to a file that needs to be moved AFTER npp is shutdown
        /// </summary>
        public bool AddFileToMove(string from, string to)
        {
            if (string.IsNullOrEmpty(from) || !File.Exists(from) || string.IsNullOrEmpty(to) || !Directory.Exists(Path.GetDirectoryName(to) ?? ""))
            {
                return(false);
            }

            // configure the update
            File.AppendAllText(Config.FileUpdaterLst, string.Join("\t", from, to) + "\r\n", Encoding.Default);

            // subscribe to the Npp shutdown event if it's not already done
            if (_typeOfExeNeeded == TypeOfExeNeeded.None)
            {
                Plug.OnShutDown += ExecuteUpdateAsync;
            }

            // test if the destination directory is writable
            var typeOfExeNeeded = Utils.IsDirectoryWritable(Path.GetDirectoryName(to)) ? TypeOfExeNeeded.UserRights : TypeOfExeNeeded.AdminRights;

            if (typeOfExeNeeded > _typeOfExeNeeded)
            {
                _typeOfExeNeeded = typeOfExeNeeded;
            }
            return(true);
        }
コード例 #2
0
ファイル: 3PUpdater.cs プロジェクト: massreuy/3P
        private void SubscribeToShutdownEvent(TypeOfExeNeeded typeOfExeNeeded)
        {
            // subscribe to the Npp shutdown event if it's not already done
            if (_typeOfExeNeeded == TypeOfExeNeeded.None)
            {
                Plug.OnShutDown += ExecuteUpdateAsync;
            }

            if (typeOfExeNeeded > _typeOfExeNeeded)
            {
                _typeOfExeNeeded = typeOfExeNeeded;
            }
        }
コード例 #3
0
ファイル: 3PUpdater.cs プロジェクト: jcaillon/3P
        /// <summary>
        /// Use to method to a file that needs to be moved AFTER npp is shutdown
        /// </summary>
        public bool AddFileToMove(string from, string to)
        {
            if (string.IsNullOrEmpty(from) || !File.Exists(from) || string.IsNullOrEmpty(to) || !Directory.Exists(Path.GetDirectoryName(to) ?? ""))
                return false;

            // configure the update
            File.AppendAllText(Config.FileUpdaterLst, string.Join("\t", from, to) + "\r\n", Encoding.Default);

            // subscribe to the Npp shutdown event if it's not already done
            if (_typeOfExeNeeded == TypeOfExeNeeded.None)
                Plug.OnShutDown += ExecuteUpdateAsync;

            // test if the destination directory is writable
            var typeOfExeNeeded = Utils.IsDirectoryWritable(Path.GetDirectoryName(to)) ? TypeOfExeNeeded.UserRights : TypeOfExeNeeded.AdminRights;
            if (typeOfExeNeeded > _typeOfExeNeeded)
                _typeOfExeNeeded = typeOfExeNeeded;
            return true;
        }