473,408 Members | 2,839 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,408 software developers and data experts.

FileSystemEventArgs

I am still "playing" with FileSystemWatcher, and have a question regarding
FileSystemEventArgs. For example, the following method is called when a file
is created:

private void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnCreated: FullPath=" + e.FullPath + "; Name=" +
e.Name);
}

But, case-sensitivity is all up the spout. If I create a file called "my
FILE.txt", then the FileSystemEventArgs will not detect the different cases,
and simply report a file called "my file.txt".

Is there any way to alter this behaviour so that FileSystemEventArgs
respects the case of the name of the created file.

Thanks,
Peter
Nov 17 '05 #1
4 4057
Hey Peter,

Since file system doesn't care about case sensitivity of files or folders,
so doe's FileSstemWatcher.

Therefor, I don't think there is a way of altering this point.

Why doe's it matter to you on CreateFile event?

- Moty -

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
I am still "playing" with FileSystemWatcher, and have a question regarding
FileSystemEventArgs. For example, the following method is called when a
file is created:

private void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnCreated: FullPath=" + e.FullPath + "; Name=" +
e.Name);
}

But, case-sensitivity is all up the spout. If I create a file called "my
FILE.txt", then the FileSystemEventArgs will not detect the different
cases, and simply report a file called "my file.txt".

Is there any way to alter this behaviour so that FileSystemEventArgs
respects the case of the name of the created file.

Thanks,
Peter

Nov 17 '05 #2
Hi, thanks for the reply.

I am making an application which logs changes in a directory and creates a
report every so often. The users who create/update files like to be able to
see the same filename case in the report I generate - so in that sense it
does matter. (I also log "rename" events - and if I am not mistaken I get
events like "my file.txt" renamed to "my file.txt" - when actually it was
"MY FILE.txt" renamed to "My File.txt", and maybe that matters to the
users...)

It also matters to me in the sense that it seems sloppy not to use the exact
case from the filesystem - then it can be up to my application to "lower" or
"upper" case it as I see fit. Now I don't get the chance.

You are right that the windows file system will not allow two files whose
names differ only in case, but somewhere the file system does "care" about
case because it can present file names in different cases in windows
explorer.

I have noticed that DirectoryInfo.GetFiles(directoryName) returns an array
of FileInfo objects which do respect the case of the filenames in the
filesystem. So some bits of .NET do care about filename case, others do not.
Irritating.

Thanks,
Peter

"Moty Michaely" <mo**@speedocs.co.il> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hey Peter,

Since file system doesn't care about case sensitivity of files or folders,
so doe's FileSstemWatcher.

Therefor, I don't think there is a way of altering this point.

Why doe's it matter to you on CreateFile event?

- Moty -

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
I am still "playing" with FileSystemWatcher, and have a question regarding
FileSystemEventArgs. For example, the following method is called when a
file is created:

private void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnCreated: FullPath=" + e.FullPath + "; Name=" +
e.Name);
}

But, case-sensitivity is all up the spout. If I create a file called "my
FILE.txt", then the FileSystemEventArgs will not detect the different
cases, and simply report a file called "my file.txt".

Is there any way to alter this behaviour so that FileSystemEventArgs
respects the case of the name of the created file.

Thanks,
Peter


Nov 17 '05 #3
Hey,

Well I guess you have your reasons :).

About rename event I am not so sure an event will raise if a file was
renamed just by it's case. Worths to check.

Anyhow, you can get the created file info as you described, this probably
would solve your problem since there is not any way to get the file's name
in the right case with FileSystemEventArgs :(.

-Moty-

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
Hi, thanks for the reply.

I am making an application which logs changes in a directory and creates a
report every so often. The users who create/update files like to be able
to see the same filename case in the report I generate - so in that sense
it does matter. (I also log "rename" events - and if I am not mistaken I
get events like "my file.txt" renamed to "my file.txt" - when actually it
was "MY FILE.txt" renamed to "My File.txt", and maybe that matters to the
users...)

It also matters to me in the sense that it seems sloppy not to use the
exact case from the filesystem - then it can be up to my application to
"lower" or "upper" case it as I see fit. Now I don't get the chance.

You are right that the windows file system will not allow two files whose
names differ only in case, but somewhere the file system does "care" about
case because it can present file names in different cases in windows
explorer.

I have noticed that DirectoryInfo.GetFiles(directoryName) returns an array
of FileInfo objects which do respect the case of the filenames in the
filesystem. So some bits of .NET do care about filename case, others do
not. Irritating.

Thanks,
Peter

"Moty Michaely" <mo**@speedocs.co.il> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hey Peter,

Since file system doesn't care about case sensitivity of files or
folders, so doe's FileSstemWatcher.

Therefor, I don't think there is a way of altering this point.

Why doe's it matter to you on CreateFile event?

- Moty -

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
I am still "playing" with FileSystemWatcher, and have a question
regarding FileSystemEventArgs. For example, the following method is
called when a file is created:

private void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnCreated: FullPath=" + e.FullPath + "; Name=" +
e.Name);
}

But, case-sensitivity is all up the spout. If I create a file called "my
FILE.txt", then the FileSystemEventArgs will not detect the different
cases, and simply report a file called "my file.txt".

Is there any way to alter this behaviour so that FileSystemEventArgs
respects the case of the name of the created file.

Thanks,
Peter



Nov 17 '05 #4
"Moty Michaely" <mo**@speedocs.co.il> skrev i en meddelelse
news:eA*************@TK2MSFTNGP15.phx.gbl...
Well I guess you have your reasons :).

About rename event I am not so sure an event will raise if a file was
renamed just by it's case. Worths to check.

Anyhow, you can get the created file info as you described, this probably
would solve your problem since there is not any way to get the file's name
in the right case with FileSystemEventArgs :(.


A rename event is indeed fired if it is only the case of the filename which
is altered.

Anyway, if anyone is interested, a "workaround" I found for my problem is:

private void OnCreated(object source, FileSystemEventArgs e)
{
Console.WriteLine("OnCreated: FullPath=" + e.FullPath + "; Name=" +
e.Name);
FileInfo fi = new FileInfo(e.FullPath);
if (fi.Exists)
{
FileInfo[] fis = fi.Directory.GetFiles(fi.Name);
Console.WriteLine(fis[0].FullName);
}
}

That is, fis[0] contains a FileInfo object which contains a filename with
the same case as the file on the filesystem.

Peter

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
8
by: Nicolas | last post by:
How do I do a RaiseEvent in csharp I'm ok in VB but csharp confused me a lot. ******* code ******** private FileSystemWatcher watcher = new FileSystemWatcher(); public delegate void...
0
by: Peter Kirk | last post by:
Hi I am trying to use FileSystemWatcher to watch for changes in a directory. The problem I am exepriencing is a double firing of an OnChanged event when a file is opened, edited, and saved. Why...
4
by: jimdscudder | last post by:
I am using a file watcher to watch for files changing. My problem is: the string file info returned is all LOWER CASE. Below is the important part of the code? Any suggestions? using...
1
by: Rocky | last post by:
I have created a windows service using vb.net which uses a filesystemwatcher to monitoe files in a specifc directory, if images are added to the directory they are resized and saved in a remote...
1
by: teslar91 | last post by:
I've been learning VB.NET for the past few weeks. One of the problems I've run into is difficulties updating controls in events from certain components, such as the FileSystemWatcher, that raise...
3
by: =?Utf-8?B?UnVkeQ==?= | last post by:
Hello All! I may have posted this problem before, but it was awhile ago. I'm working in VS 2003. I have 10 file watch process going. It seems that I can only about 6or 7 to run at the same...
8
by: Lemune | last post by:
Hi, I'm developing window service application on C# 2005. The service is to read a new excel file on certain directory, and process it to database. The service work find on XP. But when I...
2
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZyE=?= | last post by:
Where can i find this and perhaps all the other enumerations for all other types that inherit from EventArgs. I know it's a simple question. appreciated!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.