/// <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); }
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; } }
/// <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; }