Re: vb.net search network drive
- From: "Computer geek" <JohnTAllen@xxxxxxxxx>
- Date: 28 Mar 2007 05:33:55 -0700
On Mar 14, 5:17 pm, ShaneO <spc...@xxxxxxxxxxxxxxx> wrote:
Computer geek wrote:
The purpose of this program is to check various system functions at
the beginning of the day. The first one I'm doing is to check for fax
files that did not get sent over night. This is what I have so far:
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnStart.Click
'Checks network drive for files of .fax type
Dim sFiles() As String = System.IO.Directory.GetFiles("K:
\AutoFax\", String.Format("*.{0}", "fax"))
'Displays the number of fax files in the listbox
lstResults.Items.Add(String.Format("There are " &
UBound(sFiles) + 1 & " fax files waiting to be sent"))
End Sub
Ideally, I'd like to use an IF statment to test if the are more than 0
files to display what I have above. And if not, display a differnt
message. But I was not able to get an IF statement to work. I think it
has something to do with how you test a String value... The reason I
asked about pausing was because after it does the check for faxes,
I'll want it to pause briefly before moving to the next step. Just so
the display doesn't fill up real fast.
Why not just place a Label above your ListBox, that way the Label won't
scroll-off the page if there's a lot of files being listed -
Dim sFiles() As String = System.IO.Directory.GetFiles("K:\AutoFax\",
"*.fax")
If sFiles.Length > 0 Then
Label1.Text = String.Format("There are {0} fax files waiting to be
sent", sFiles.Length)
Else
Label1.Text = "All faxes have been successfully sent."
End If
Note the following points:
1. I've removed your String.Format function from the first line. It was
illogical to use it with a known value like "fax". If you know the
value, then just use it in the string.
2. I've included the "If" that you mentioned you wanted.
3. Generally, watch out for the way you're using "String.Format". Take
another look at your second line.
4. This may be a little ahead of you at this time, but, if you decide to
use the Label option I've suggested and you're going to check for
additional files, do your next check and just add to the already
displayed Label Text. eg. - Label1.Text = Label1.Text & vbCrLf &
String.Format("There are also {0} whatever files waiting to be sent",
sWhatever.Length)
I hope this helps you.
ShaneO
There are 10 kinds of people - Those who understand Binary and those who
don't.- Hide quoted text -
- Show quoted text -
Do either of you know of any good online resources that clearly define
different functions/methods in vb.net? I've found a couple sites but
they are not very intuitive for a beginner like myself.
.
- References:
- vb.net search network drive
- From: Computer geek
- Re: vb.net search network drive
- From: ShaneO
- Re: vb.net search network drive
- From: ShaneO
- Re: vb.net search network drive
- From: Computer geek
- Re: vb.net search network drive
- From: rowe_newsgroups
- Re: vb.net search network drive
- From: Computer geek
- Re: vb.net search network drive
- From: rowe_newsgroups
- Re: vb.net search network drive
- From: ShaneO
- Re: vb.net search network drive
- From: Computer geek
- Re: vb.net search network drive
- From: rowe_newsgroups
- Re: vb.net search network drive
- From: Computer geek
- Re: vb.net search network drive
- From: ShaneO
- vb.net search network drive
- Prev by Date: Moving Files
- Next by Date: looping and printing to a printer??
- Previous by thread: Re: vb.net search network drive
- Next by thread: Re: Checking for A Blank String
- Index(es):
Relevant Pages
|