public void DeleteAttachementAction(object o) { string path = CurrentNode.Value.Path; AttachementPath = null; var node = CurrentNode; RuleAttachementsList.Remove(CurrentNode); CurrentNode = node.Next; //CurrentNode = CurrentNode.Next; File.Delete(path); CurrentNode = RuleAttachementsList.First; ReArrangeList(); CurrentNode = RuleAttachementsList.Last; AttachementPath = CurrentNode.Value.Path; }
public void AddAttachementAction(object o) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; if (openFileDialog.ShowDialog() == true) { //Get the path of specified file sourcePath = openFileDialog.FileName; fileExtension = Path.GetExtension(sourcePath); //destinationPath = @"\\10.10.46.103\attachements\" + CurrentRule.IssuerId + "\\" + CurrentRule.RuleYear + "-" + CurrentRule.AnnualSerialNumber + "\\" + (RuleAttachementsList.Count + 1) + fileExtension; destinationPath = @"D:\\attachements\" + CurrentRule.IssuerId + "\\" + CurrentRule.RuleYear + "-" + CurrentRule.AnnualSerialNumber + "\\" + (RuleAttachementsList.Count + 1) + fileExtension; AttachementPath = sourcePath; RuleAttachementsList.AddLast(new LinkedListNode <RuleAttachement>( new RuleAttachement { RuleId = CurrentRule.RuleId, AttachmentNumber = Convert.ToInt16(RuleAttachementsList.Count + 1), Path = destinationPath })); CurrentNode = RuleAttachementsList.Last; //uploadedNewFile = true; Directory.CreateDirectory(Path.GetDirectoryName(destinationPath)); File.Copy(sourcePath, destinationPath, true); } }