2017-09-05 12 views
-10

私は私が発見した次のコードを持ってはVB.NETであり、私はそれが選ぶPNGの画像を取得している際に、わずかにそれを修正したいと思いますフォルダからの最大ファイルサイズどのような助けが大いに感謝!選択イメージファイル(最大ピック)

Imports system.data 
imports system.io 
imports system.windows.forms 
Imports system.drawing 

Private Sub xtraReport1_BeforePrint(ByVal sender As Object, ByVal e As 
System.Drawing.Printing.PrintEventArgs) 
Dim ReportDS As system.data.dataset = CType(Report.DataSource, 
System.Data.DataSet) 

if CType(Report.DataSource, DataSet).Tables("Data").Rows.Count = 0 then 
Exit Sub 
End if 

if CType(Report.DataSource, 
DataSet).Tables("Data").columns.contains("CourierLabel") = false then 
CType(Report.DataSource, DataSet).Tables("Data").columns.add("CourierLabel", 
gettype(String)) 
end if 

Dim ExportPath as string = SystemBusiness.Executescalarstr("select 
cod_cdd_export_path from courier_detail where cod_id = " & 
CType(Report.DataSource, DataSet).Tables("Data").rows(0).item("dh_cod_id")) 

Dim DelNumber as string = CType(Report.DataSource, 
DataSet).Tables("Data").rows(0).item("dh_number").tostring 
Dim DelDate as string = cdate(CType(Report.DataSource, 
DataSet).Tables("Data").rows(0).item("dh_datetime")).tostring("yyyy-MM-dd") 

Dim DirPath as string = System.IO.Path.Combine(ExportPath, DelDate, 
DelNumber) 
'DirPath = "C:\temp" 

For each f as string In Directory.GetFiles(DirPath) 

if f.contains("png") Then 
CType(Report.DataSource, 
DataSet).Tables("Data").rows(0).item("CourierLabel") = 
System.IO.Path.Combine(DirPath, f) 
'messagebox.show(System.IO.Path.Combine(DirPath, f)) 
'system.windows.forms.messagebox.show(System.IO.Path.Combine(DirPath, f)) 
PictureBox1.Image = Image.FromFile(System.IO.Path.Combine(DirPath, f)) 
picturebox1.image.rotateflip(RotateFlipType.Rotate90FlipNone) 

end if 

Next 

End Sub 
+5

)。これはCまたはC++ではありません。 – NathanOliver

+1

私は多くの言語タグを見て質問を開いて興味をそそられました! – CinCout

+0

ありがとう、私はそれが自動的に固定されていると思います。うまくいけば誰かが助けることができるでしょう。 – Tom

答えて

1

その基本:(

私は移動するための方法を提供することができます。

まず最大のファイルを見つける: maxFileSizeの= 0;大きな場合、 ループファイルとmaxFileSizeので、各ファイルサイズを比較あなたは、ディレクトリの最大のファイルへのパスを持っているループ後filePathに。 を保存します。

Dim maxFileSize = 0 
Dim filePath = Nothing 
For each f as string In Directory.GetFiles(DirPath) 
    if f.Size > maxFileSize Then 
     maxFileSize = f.Size 
     filePath = f.FullPath 
    end if 
Next 

- 私f.Sizeとf.FullPathわからが、これは、デバッガでは解決が容易であるべきではない。私は、これはVBAであると考えて

+0

右の感謝、ありがとう。コードでどのように見えるかわからないと思いますか? – Tom

関連する問題