//public static bool TryCopy(string srcPath, string destPath) //{ // if (!System.IO.File.Exists(srcPath)) // return false; // try // { // string destThn = ImageItem.GetThumbnailPathAndFileName(destPath); // string srcThn = ImageItem.GetThumbnailPathAndFileName(srcPath); // string destTxt = ImageItem.GetTextFilePathAndFileName(destPath); // string srcTxt = ImageItem.GetTextFilePathAndFileName(srcPath); // System.IO.File.Copy(srcPath, destPath); // if (System.IO.File.Exists(srcThn)) // System.IO.File.Copy(srcThn, destThn); // if (System.IO.File.Exists(srcTxt)) // System.IO.File.Copy(srcTxt, destTxt); // return true; // } // catch (Exception ex) // { // _appLog.LogError(String.Format("Failed to copy file {0}", srcPath), ex, "SlideShowSetupForm", "TryCopy"); // return false; // } //} //public static bool TryMove(string srcPath, string destPath) //{ // if (!System.IO.File.Exists(srcPath)) // return false; // try // { // string destThn = ImageItem.GetThumbnailPathAndFileName(destPath); // string srcThn = ImageItem.GetThumbnailPathAndFileName(srcPath); // string destTxt = ImageItem.GetTextFilePathAndFileName(destPath); // string srcTxt = ImageItem.GetTextFilePathAndFileName(srcPath); // System.IO.File.Move(srcPath, destPath); // if (System.IO.File.Exists(srcThn)) // System.IO.File.Move(srcThn, destThn); // if (System.IO.File.Exists(srcTxt)) // System.IO.File.Move(srcTxt, destTxt); // return true; // } // catch (Exception ex) // { // _appLog.LogError(String.Format("Failed to move file {0}", srcPath), ex, "SlideShowSetupForm", "TryMove"); // return false; // } //} public static bool TryDelete(string srcPath) { if (!System.IO.File.Exists(srcPath)) { return(false); } try { string srcThn = ImageItem.GetThumbnailPathAndFileName(srcPath); string srcTxt = ImageItem.GetTextFilePathAndFileName(srcPath); System.IO.File.Delete(srcPath); if (System.IO.File.Exists(srcThn)) { System.IO.File.Delete(srcThn); } if (System.IO.File.Exists(srcTxt)) { System.IO.File.Delete(srcTxt); } return(true); } catch (Exception ex) { AppLog appLog = new AppLog(); appLog.LogError(String.Format("Failed to delete file {0}", srcPath), ex, "SlideShowSetupForm", "TryDelete"); return(false); } }
private static bool TryCopy(string srcPath, string destPath, string verb, CopyDel copyDel) { if (!System.IO.File.Exists(srcPath)) { return(false); } try { string destThn = ImageItem.GetThumbnailPathAndFileName(destPath); string srcThn = ImageItem.GetThumbnailPathAndFileName(srcPath); string destTxt = ImageItem.GetTextFilePathAndFileName(destPath); string srcTxt = ImageItem.GetTextFilePathAndFileName(srcPath); copyDel(srcPath, destPath); if (System.IO.File.Exists(srcThn)) { copyDel(srcThn, destThn); } if (System.IO.File.Exists(srcTxt)) { copyDel(srcTxt, destTxt); } return(true); } catch (Exception ex) { AppLog appLog = new AppLog(); appLog.LogError(String.Format("Failed to {0} file {1}", verb, srcPath), ex, "SlideShowCommon.Utilities", "Try" + verb); return(false); } }