2017-03-26 6 views
-3
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using System.IO; 
using System.Diagnostics; 

namespace Test 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      using (FolderBrowserDialog fbd = new FolderBrowserDialog() { Description = "Select your path" }) 
      { 
       if (fbd.ShowDialog() == DialogResult.OK) 
        tbxFrom.Text = fbd.SelectedPath; 
      } 
     } 

     private void button2_Click(object sender, EventArgs e) 
     { 
      var myLyndaFiles = Directory.GetFiles(tbxFrom.Text, ".lynda"); 
      var lynda = Directory.GetFiles(tbxProgrammLocation.Text, ".exe"); 
      for (int i = 0; i < myLyndaFiles.Length; i++) 
      { 
       Process.Start(@"C:\WINDOWS\system32\cmd.exe", lynda[0] + " /F " + myLyndaFiles[i] + " " + tbxTo.Text + "\n"); 
       tbxOut.Text = i.ToString(); 
      } 
     } 

     private void button3_Click(object sender, EventArgs e) 
     { 
      using (FolderBrowserDialog fbd = new FolderBrowserDialog() { Description = "Select your path" }) 
      { 
       if (fbd.ShowDialog() == DialogResult.OK) 
        tbxTo.Text = fbd.SelectedPath; 
      } 
     } 

     private void btnStartFrom_Click(object sender, EventArgs e) 
     { 
      using (FolderBrowserDialog fbd = new FolderBrowserDialog() { Description = "Select your path" }) 
      { 
       if (fbd.ShowDialog() == DialogResult.OK) 
        tbxProgrammLocation.Text = fbd.SelectedPath; 
      } 
     } 
    } 
} 

私を助けてください!理由は分かりませんが、Directory.GetFilesのように動作しません。私はブレークポイント経由でvar myLyndaFilesを調べましたが、それは多かれ少なかれ[0] - >ですが、そこに20以上のファイルがあります...期待どおりに機能しないのはなぜですか?

+1

郵便のみ必要なコード – Sajeetharan

+0

PSをこれらの入力です: – limak1109

+0

tbxProgrammLocation: C:プロジェクト\テスト\カミル\ドキュメントは、Visual Studio 2015を\ \ \ユーザーは、 – limak1109

答えて

1

あなたの拡張ファイルにワイルドカードを追加することになっています):

var myLyndaFiles = Directory.GetFiles(tbxFrom.Text, "*.lynda"); 
var lynda = Directory.GetFiles(tbxProgrammLocation.Text, "*.exe"); 

ない:

var myLyndaFiles = Directory.GetFiles(tbxFrom.Text, ".lynda"); 
var lynda = Directory.GetFiles(tbxProgrammLocation.Text, ".exe"); 
+0

偉大なthxはそれを見ませんでした:P – limak1109

関連する問題