|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
FileSystemWatcher: Fix for lowercase?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 "Paul" <priv***@private.com> schrieb: That didn't work for me. 'Name'/'FullName' returned the same string that > 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. 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/> 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 Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:%23tmRNVrMFHA.2680@TK2MSFTNGP09.phx.gbl... > "Paul" <priv***@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/>
Locate MessageBox over Window
REALbasic 5.5 free to VB6 Users Untili March 31 2005 spice the boring default winforms treeview appearance up a bit... Help with SendMessage API calls Error with Custom Control Closing form... MaskedEdit Control Friend WithEvents Tabcontrol tabpagebutton orientation Object reference not set to an instance of an object. |
|||||||||||||||||||||||