/// <summary> /// Get the hidden attribute from the file corresponding to this task. /// </summary> /// <returns>The value of the attribute.</returns> private bool GetHiddenFileAttr() { IPersistFile iFile = (IPersistFile)iTask; string fileName; iFile.GetCurFile(out fileName); System.IO.FileAttributes attr; try { attr = System.IO.File.GetAttributes(fileName); return((attr & System.IO.FileAttributes.Hidden) != 0); } catch { return(false); } }
/// <summary> /// Saves the Task with a new name. The task with the old name continues to /// exist in whatever state it was last saved. It is no longer open, because. /// the Task object is associated with the new name from now on. /// If there is already a task using the new name, it is overwritten. /// </summary> /// <remarks>See the <see cref="Save()"/>() overload.</remarks> /// <param name="name">The new name to be used for this task.</param> /// <exception cref="COMException">Unable to establish existence of the account specified.</exception> public void Save(string name) { IPersistFile iFile = (IPersistFile)iTask; string path; iFile.GetCurFile(out path); string newPath; newPath = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + name + Path.GetExtension(path); iFile.Save(newPath, true); iFile.SaveCompleted(newPath); /* probably unnecessary */ this.name = name; SetHiddenFileAttr(Hidden); //Do the Task Scheduler's work for it because it doesn't reset properly }
/// <summary> /// Set the hidden attribute on the file corresponding to this task. /// </summary> /// <param name="set">Set the attribute accordingly.</param> private void SetHiddenFileAttr(bool set) { IPersistFile iFile = (IPersistFile)iTask; string fileName; iFile.GetCurFile(out fileName); System.IO.FileAttributes attr; attr = System.IO.File.GetAttributes(fileName); if (set) { attr |= System.IO.FileAttributes.Hidden; } else { attr &= ~System.IO.FileAttributes.Hidden; } System.IO.File.SetAttributes(fileName, attr); }