public MkLinkResult MkLinkTo(string link, bool overwrite, MkLinkParameter?filePara = null, MkLinkParameter?dirPara = null) { if (!isSource) { throw new NotSupportedException("Wrapper instance created using link is not supported for this function"); } return(MkLink.Execute(link, source, GetParameter(filePara, dirPara), overwrite)); }
public MkLinkResult MoveAndMkLinkHere(string link, bool mix, bool?copyAndDelete = null, MkLinkParameter?filePara = null, MkLinkParameter?dirPara = null) { copyAndDelete ??= CopyAndDeleteInsteadOfMove; if (!isSource) { throw new NotSupportedException("Wrapper instance created using link is not supported for this function"); } try { if (isFile) { if (copyAndDelete.Value) { File.Copy(source, link); File.Delete(source); } else { File.Move(source, link); } } else { if (copyAndDelete.Value) { DirectoryInfo di = new DirectoryInfo(source); CopyAll(di, new DirectoryInfo(link)); } else { Directory.Move(source, link); } } } catch (Exception e) { return(new MkLinkResult() { IsSuccessful = false, FailedStep = MkLinkFailedStep.FileOperationBeforeAll, Exception = e }); } return(MkLink.Execute(source, link, GetParameter(filePara, dirPara))); }
public MkLinkResult MkLinkHere(string source, bool overwrite, MkLinkParameter?filePara = null, MkLinkParameter?dirPara = null) { if (isSource) { throw new NotSupportedException("Wrapper instance created using source is not supported for this function"); } if (File.Exists(source)) { isFile = true; } else if (Directory.Exists(source)) { isFile = false; } else { // File Not Found , do not throw exception here. isFile = true; source = ""; } return(MkLink.Execute(link, source, GetParameter(filePara, dirPara), overwrite)); }