There must be something wrong with your code, the dwVolumeSerialNumber is
the "volume serial" number and as such doesn't change (unless you format the
volume). All files on a volume will return the same value (the value isn't
even a file attribute, it's a volume attribute).
Anyway, you can't use this API to uniquely identify a file on a FS.
Willy.
| Hi:
|
| I thought that dwVolumeSerialNumber would give me a serial number for the
| volume as well.
|
| However, it is giving me a different value for each file, which remains
even
| if I change the filename. If I make a NEW file with the same name, that
NEW
| file gets a different value.
|
| What I think it might be is that it is giving me a serial number for the
| file specific to that volume, not a serial number for the volume itself?
|
| Any thoughts?
|
| If I create a GUID for the file, how does it key to the file? If I move
the
| file around on the file system, update the contents of the file, etc,
would
| it stick?
|
| Thanks
|
|
| | > The dwVolumeSerialNumber is a volume serial number, all files on that
| > volume
| > will have the same dwVolumeSerialNumber.
| > Why don't you create an guid using the Guid.NewGuid method and use this
to
| > identify the file?
| >
| > Willy.
| >
| > | > | The HashCode changes if the file is renamed.
| > |
| > | When I go through the API using GetFileInformationByHandle the
returned
| > | dwVolumeSerialNumber does not change if the file is renamed.
| > |
| > | Based on that I wanting a unique identifier for each file on the
| > filesystem
| > | even if a) the filename changes b)the path changes or c) the contents
| > change
| > | would dwVolumeSerialNumber be sufficicient or is not appropriate to
use
| > that
| > | as my identifier?
| > |
| > | Thanks.
| > |
| > |
| > | | > | > thank you - I will check it out
| > | >
| > | >
| > | > "Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT
dot.state.fl.us>
| > | > wrote in message | > | >> Hi,
| > | >>
| > | >> Check this thread:
| > | >>
| > | >>
| >
http://groups.google.com/group/micr...osoft.public.dotnet.*&rnum=3#5ef72cef1b0849a2
| > | >>
| > | >>
| > | >> Cheers,
| > | >>
| > | >> --
| > | >> Ignacio Machin,
| > | >> ignacio.machin AT dot.state.fl.us
| > | >> Florida Department Of Transportation
| > | >>
| > | >>
| > | >> | > | >>> Thanks for the response, Willy.
| > | >>>
| > | >>> What I am trying to achieve is to index a series of files in a
| > directory
| > | >>> into a database. I need a unique identifier for each field. I
| > cannot
| > | >>> use filename and path, because I do not want to lose my reference
to
| > the
| > | >>> file, even if the file name changes.
| > | >>>
| > | >>> When I use GetFileInformationByHandle function and reference
| > | >>> dwVolumeSerialNumber it gives me the number, and is the same
number
| > per
| > | >>> file even if rerun the program. This would not be the appropriate
| > | >>> identifier?
| > | >>>
| > | >>> Any thoughts?
| > | >>>
| > | >>> Thanks for your help on this. Much appreciated.
| > | >>>
| > | >>>
| > message
| > | >>> | > | >>>> There is no such thing like a GUID for a file or a file system.
| > | >>>> The API your are talking about (I guess, because you did not
| > mention
| > | >>>> it), is
| > | >>>> GetFileInformationByHandle which returns a pointer to a
| > | >>>> BY_HANDLE_FILE_INFORMATION structure.
| > | >>>> I guess the "unique number" you get, is the pointer value to the
| > | >>>> structure
| > | >>>> in memory, which has nothing to do with a GUID. What exactly are
| > you
| > | >>>> trying
| > | >>>> top achieve?
| > | >>>>
| > | >>>>
| > | >>>> Willy.
| > | >>>>
| > | >>>>
| > | >>>> | > | >>>> | Hi:
| > | >>>> |
| > | >>>> | I need to get the unique GUID for a file, so I am using API
calls
| > | >>>> through
| > | >>>> | System.InteropServices
| > | >>>> |
| > | >>>> | I am using
| > | >>>> | BY_HANDLE_FILE_INFORMATION
| > | >>>> |
| > | >>>> | and
| > | >>>> |
| > | >>>> | dwVolumeSerialNumber
| > | >>>> |
| > | >>>> | to get the unique FileSystem GUID for a particular file. Is
this
| > the
| > | >>>> | appropriate property? I am getting unique numbers for each
file
| > I
| > | >>>> run it
| > | >>>> | for, so it looks like the right one, but I am not sure.
| > | >>>> |
| > | >>>> | The documentation says it is the unique serial for the volume
of
| > the
| > | >>>> file,
| > | >>>> | but I want the unique serial for the file itself.
| > | >>>> |
| > | >>>> | Thanks!
| > | >>>> |
| > | >>>> |
| > | >>>>
| > | >>>>
| > | >>>
| > | >>>
| > | >>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|