I am currently working in VB.NET visual studio express 2013 with an SQL back end. I have an sql query that pulls a list of jobs from an sql server. From there, this list is populating into a combo box for a production supervisor to push jobs into manufacturing. The supervisor can push jobs to several different machines. However, each list has some "empty" jobs, as in, he can push that job to any machine but that machine may have no tasks assigned to that job. To remove the blank entries from the list I am going to have to look up each individual PDF file that has that job description, based on a date time, and retrieve the file size. Since the pdf is automatically generated a blank file will always have the same file size. I will then cross reference the file size and if it equal or under the empty file size it will remove it from the list. I am getting hung up on the cross reference of comparing the file size. When I try and compare the size of a file with an integer it throws me an error and I can't seem to figure out why, im fairly new to the IO bit of VB.Net. Heres my code:
For Each row As DataRow In dt.Rows
Try
Dim year As String = Now.Year
'Dim InfoReader As System.IO.FileInfo
inforeader = My.Computer.FileSystem.GetFileInfo("document.pdf")
'MsgBox("File is " & InfoReader.Length & "bytes")
Catch ex As Exception
Dim year As String = Now.Year
'Dim InfoReader As System.IO.FileInfo
inforeader = My.Computer.FileSystem.GetFileInfo("document.pdf")
'MsgBox("File is " & InfoReader.Length & "bytes")
End Try
If inforeader.Length <= 3333 Then
row.Delete()
End If
Next row
Please note that I removed the actual pdf file pathway for both space savings and company protection. Also, do not worry about the year or comments, it is part of the program. My problem is with the "inforead.length <= 3333"
EDIT (Solution)----------------------------------------------------------
Dim TheSize As ULong = My.Computer.FileSystem.GetFileInfo(document.pdf").Length
Select Case TheSize
Case Is >= 1
MsgBox("Blamo")
End Select
This is working
Thanks,
Can you place that code in a Try-Catch block so we can catch and output the exception? I suspect it could possibly have something to do with your DataTable
.
Try
If inforeader.Length <= 3333 Then
row.Delete()
End If
Catch (ex As Exception)
MessageBox.Show(ex.Message)
End Try