2017-04-24 24 views
0

ファイルのディレクトリをファイル名の昇順で印刷したいのですが(私にとっては起こりません - ファイルの作成順序ではデフォルトのようです)。ファイルをファイル名順に印刷する

コード:

Dim PrintPDF As New ProcessStartInfo 
For Each fileName1 In Directory.GetFiles(strALPRMailOutReports, "*.pdf", SearchOption.AllDirectories) 
    PrintPDF.UseShellExecute = True 
    PrintPDF.Verb = "print" 
    PrintPDF.WindowStyle = ProcessWindowStyle.Hidden 
    fileNameOnly = Path.GetFileName(fileName1) 
    PrintPDF.FileName = strALPRMailOutReports & "\" & fileNameOnly 
    Process.Start(PrintPDF) 
Next 
+0

[ドキュメント](https://msdn.microsoft.com/en-us/library/07wt70x2.aspx)から: "返されるファイル名の順序は保証されていません。特定の並べ替え順序が必要です。 –

+0

Pardon私はVBコーディングでは新しいですが、上記のコードを印刷用に組み込む方法の例を挙げてください。 – AlanGrant

+0

コーディさんありがとうございます。それは今働く。 – AlanGrant

答えて

1

簡単なソートは、トリックを行います。

Dim files() As String = IO.Directory.GetFiles("Path here") 
Array.Sort(files) 
For Each fileName1 In files 
    'Print fileName1 
Next 
+0

EuX0ありがとうございます。それは私のために働く! – AlanGrant

関連する問題