[英]C# : saving screenshot into a sub directory within the app base directory?
[英]Exclude Sub Folder Within Directory C#
將目錄復制到其他位置時,我想排除目錄中的文件夾,有人可以幫我嗎?
string logZipTarget = "PangaeaLogs_Fail_" + currentLocation + "_" + classID + "_" + tracer + "_" +
DateTime.Now.ToString("ddMMMyyyy-HH-mm-ss", System.Globalization.CultureInfo.InvariantCulture) + ".zip";
string buildTypeFile = @"C:\build.typ";
string journalFile = @"C:\Mavis\" + tracer + ".ejl";
string logsPath = @"C:\Pangaea\PangaeaFinancialLogs\"; //Path to copy directory to
File.Copy(buildTypeFile, logsPath + "build.typ", true);
File.Copy(journalFile, logsPath + tracer + ".ejl", true);
Helper.DirectoryCopy(@"C:\Program Files\NCR\Pangaea\", logsPath, true);
executor.ZipFolder(logsPath, logZipTarget);
在這個位置C:\\Pangaea\\PangaeaFinancialLogs\\ApplicationData我想刪除這個文件夾SessionBackup但發生的事情是它復制了這個位置字符串 logsPath = @"C:\\Pangaea\\PangaeaFinancialLogs\\";
從您的評論中提供的一些代碼來看,我只能假設您使用的是哪些類。 如果我是對的,這應該可以解決問題:
DirectoryInfo currentFolder = new DirectoryInfo("");
String NameOfFolderNotToInclude = "";
if(currentFolder.Name != NameOfFolderNotToInclude)
{
File.Copy(newPath, newPath.Replace(@"\\xxx\yyy", @"C:\bbb"), true);
}
請始終記住,如果未覆蓋,則等於 ( MSDN ) 將始終比較實際對象的相等性。 在您的情況下,字符串永遠不會與 DirectoryInfo 相同,因此即使 DirectoryInfo 指向字符串描述的位置也不相等。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.