By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,692 Members | 1,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,692 IT Pros & Developers. It's quick & easy.

FileSystemWatcher: Fix for lowercase?

P: n/a
Hi,
As most people who use the FileSystemWatcher know, it returns lowercase text
for some strange reason. I know there's a workaround for the lowercase the
FileSystemWatcher returns by by passing the 'FullPath' property into the
constructor of a DirectoryInfo Class and reading the 'Name' property but I'm
not sure how or where I'd fit that into my code.
Could someone point me in the right direction?

Cheers,
Paul

Code follows..........

Private Sub LogChange(ByVal source As Object, ByVal e As
FileSystemEventArgs)
Dim strDestDir As String = "D:\"
Dim strString As String

Select Case e.ChangeType
Case IO.WatcherChangeTypes.Created
Try
If File.Exists(strDestDir & e.Name) = True Then
'File already exists in dest dir, wait for new file to
become available/not locked then delete it
Do Until FileIsReady(e.FullPath) = True
Loop
File.Delete(e.FullPath)
Exit Sub
Else
'File doesn't exist, wait for new file to become
available then move it.
Do Until FileIsReady(e.FullPath) = True
Loop
'Call popup form passing full path (lowercase for some
reason)
Popup(e.FullPath)
File.Move(e.FullPath, strDestDir & e.Name)
End If
Catch indexProblem As IndexOutOfRangeException
MsgBox("Error - No filename supplied")
Catch ioProblem As System.IO.IOException
'IOException error other than 'File already exists' (which
is checked above.)
MsgBox("Error - Can't process file named: " & e.FullPath)
End Try
End Select
End Sub

Function FileIsReady(ByVal sFileName As String) As Boolean
'Returns False if file is already opened by another process and the
'specified type of access is not allowed, the Open operation fails.
Dim nFileNum As Integer

nFileNum = FreeFile()
Try
FileOpen(nFileNum, sFileName, OpenMode.Binary, OpenAccess.Write)
FileClose(nFileNum)
Return True
Catch
Return False
End Try
End Function
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Paul" <pr*****@private.com> schrieb:
As most people who use the FileSystemWatcher know, it returns lowercase
text for some strange reason. I know there's a workaround for the
lowercase the FileSystemWatcher returns by by passing the 'FullPath'
property into the constructor of a DirectoryInfo Class and reading the
'Name' property but I'm not sure how or where I'd fit that into my code.


That didn't work for me. 'Name'/'FullName' returned the same string that
was passed to the 'DirectoryInfo''s constructor (.NET 1.1 SP1, Windows XP
Professional SP2).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
So there's no way of fixing the case? Suppose the next best thing is making
the start of each word a capital then. Pain!

Cheers,
Paul

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Paul" <pr*****@private.com> schrieb:
As most people who use the FileSystemWatcher know, it returns lowercase
text for some strange reason. I know there's a workaround for the
lowercase the FileSystemWatcher returns by by passing the 'FullPath'
property into the constructor of a DirectoryInfo Class and reading the
'Name' property but I'm not sure how or where I'd fit that into my code.


That didn't work for me. 'Name'/'FullName' returned the same string that
was passed to the 'DirectoryInfo''s constructor (.NET 1.1 SP1, Windows XP
Professional SP2).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.