• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

file.length

How can I fix this see below. If the file is exactly 180kb, delete it.



For Each myfileInfo In myDir1.GetFiles("*.jpg")

ix += 1

If myfileInfo.Length <= 10 * 1024 Then

myfileInfo.MoveTo("F:\MailBox\temp\" & "ThisFileIsLessthanTenKb - " & _

DateTime.Now.ToString("yyyyMMddHHmmss") & "." & ix & ".jpg")

ElseIf myfileInfo.Length = 10 * 180000 Then              ------------- this line -------------------------

myfileInfo.Delete()





End If

jpgCount = myDir1.GetFiles("*.jpg").Length

Me.Label23.Text = jpgCount.ToString
0
VBdotnet2005
Asked:
VBdotnet2005
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ElseIf myfileInfo.Length = 1024 * 180 Then  
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ie 180KB meaning exactly 180 * 1024 bytes.

if you means anything from 180KB + 0bytes up to 180KB + 1023 bytes, the condition would be different of course...
0
 
VBdotnet2005Author Commented:

Sorry, it does not move. What could it be. It is an image file.

For Each myfileInfo In myDir1.GetFiles("*.jpg")

ix += 1

If myfileInfo.Length <= 10 * 1024 Then

myfileInfo.MoveTo("F:\MailBox\temp\" & "ThisFileIsLessthanTenKb - " & _

DateTime.Now.ToString("yyyyMMddHHmmss") & "." & ix & ".jpg")

ElseIf myfileInfo.Length = 180 * 1024

myfileInfo.Delete()





End If

jpgCount = myDir1.GetFiles("*.jpg").Length

Me.Label23.Text = jpgCount.ToString
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now