473,366 Members | 1,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,366 software developers and data experts.

FileSystemWatcher: Fix for lowercase?

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
2 1328
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Troy Murphy | last post by:
How do I prevent the FileSystemWatcher event to keep firing while the file is being created? When copying a file to the watched folder, the event fires a dozen or more times! Also, the...
7
by: Allen Anderson | last post by:
I'm trying to figure out a way to catch when a file has been written to a directory. I currently have it where I can catch when the file begins writing, but this isn't helpful as I need to know...
2
by: Jet Leung | last post by:
Hi all, I had made a program to watching files in my directory. I had used a instance of FileSystemWatcher to do my work.And I had add some events of the FileSystemWatcher , for example onChange,...
13
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just...
3
by: Stampede | last post by:
Hi, I want to use the FileSystemWatcher in a Windows Service. I read an article, where the author created the FileSystemWatcher object in a seperate thread and when the event is fired, he started...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
12
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
5
by: Goran Djuranovic | last post by:
Hi all, I have a file system watcher service that works fine on a local hard drive, but will not work across the network. I tried both: mapping the drive and "\\..." path both no luck. I don't...
5
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.