-1

ファイルを読み取ってパスを取得し、そのパスを検索しようとしています。

C:\Users\Public\Documents\ScriptPath.txt には「C:\Users\Public\Music Folder\」が含まれています

ここに私のコードがあります

        string ScriptPath = System.IO.File.ReadAllText(@"C:\Users\Public\Documents\ScriptPath.txt"); 

        System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(ScriptPath);
        System.Threading.Thread.Sleep(2000);

        foreach (System.IO.FileInfo file in dir.GetFiles("*.*"))
        {
            MessageBox.Show("{0}, {1}" + file.Name+ file.Length);
        }

私が得るエラーはこれです。

ArgumentException が処理されませんでした

タイプ 'System.ArgumentException' の未処理の例外が mscorlib.dll で発生しました

追加情報: パスに不正な文字があります。

なぜこれが機能しないのかを理解するのを手伝ってくれる人がいれば、私は感謝しています。

4

1 に答える 1