2016-11-26 17 views
-5

我正在開發一個C#應用程序,需要在某個文件夾中運行REN . *.jpg。我如何使用C#編寫代碼。我正在使用Visual Studio 2015社區,我的應用程序是一個窗體窗體。 我想複製全部文件在一個特定的文件夾中Cmd Ren *。* * .jpg在c#

+1

[執行批處理文件在C#]的可能的複製(http://stackoverflow.com/questions/5519328/executing-batch-file-in-c-sharp) – devRicher

+0

如果你想重命名一個文件,而不使用像REN這樣的命令行工具,你應該看看http://stackoverflow.com/questions/3218910/rename-a-file-in-c-sharp – Steve

+0

@devRicher:我認爲他更好關閉它在C#中編碼而不是運行批處理文件。提及批次只是澄清意圖的一種方式。 – Dani

回答

0

我試圖找到一種方法。但是,對於那些誰需要幫助:

foreach (var srcPath in Directory.GetFiles(tmppath)) 
{ 
    //To customize for yourself: 
    //replace "tmppath" with what ever you want 
    File.Move(srcPath, srcPath+".jpg"); 
}