Jump to content
Xtreme .Net Talk

jhermiz

Members
  • Posts

    3
  • Joined

  • Last visited

jhermiz's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I cannot use that since I am not looking for multiple files, I am only looking at 3 distinct files. Are you saying to use the FileInfo object on three seperate instances which are ALL in the same folder?
  2. Can you please post an example of this regular expression and how it fits my needs I'd be very interested, For your second example I cannot use a simple loop, my requirement is to have the app wait for five minutes before checking for a total of five checks. Any more help is greatly appreciated ?
  3. I need a way to rename a file without knowing the EXACT name of the file..for instance I need to use wild card *. For instance say I have c:\temp\test1242325365.txt I would like to be able to rename this in my app like: fi = New FileInfo("c:\temp\test*.txt") If fi.Exists() Then fi.MoveTo(c:\temp2\zgpsout.txt") End If I want to be able to say test* rather than the actual name of the file because I will never know the exact name..all I will know is that it may start with "test" and end with ".txt" That is my first question. My second question is I need to check if a file is locked...if it is I need my code to wait for 5 minutes and try again..upto 5 times. I am getting no where with this...can someone show me how to "stop" my app for 5 minutes: Private Sub CheckLock() Dim myFileStream As Stream Dim fi As FileInfo fi = New FileInfo(strPL1SAPPath & "\ZGPSIN0001_OUTBOUND_.txt") If fi.Exists() Then Try 'try to open it to see if it was locked myFileStream = New FileStream(strPL1SAPPath & "\ZGPSIN0001_OUTBOUND_.txt", FileMode.Open, FileAccess.Read) 'if an exception occurs the file is locked Catch ex As Exception i = i + 1 'try for 5 times i is [b]global[/b] If i = 5 Then MailException("An error occurred when checking if file was locked." & Chr(13) & Chr(13) & ex.ToString()) Application.Exit() Else CheckLock() End If Finally If Not (myFileStream Is Nothing) Then myFileStream.Close() End Try End If End Sub Does that code make sense? Basically I try to open a file, if it is locked it hits that exception and i is incremented by 1...and recalls that function. But I need to sleep(5 minutes) before recallign that function... Jon
×
×
  • Create New...