Click here to Skip to main content
15,891,863 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Ultimate goal:
My ultimate goal is to organise a humongous mess of files in an application.
A bit like in photography there are Standard properties (TAGs?) that all files could have (e.g. Camera, Aperture, Date, etc.) and also categories (tags) that users fancy (e.g. Brother, Sunset, Nature).
Ultimately the organising principle for the files are not up to me to decide.
That doesn't mean that I wont recommend a structure, but it means that using tags to power a search and categorisation tool would be a great.
Often the user inherits a mess of files where the filename it self in a cryptic way tells about the origin and could suggest TAGS to use on the basis of that. For this purpose a tag that follows the file would be great.

I have been looking for methods to tag files from within a WPF application. The files to tag will be any files in a folder structure (on local hard drives or on network drives) the files are text and binary (proprietary) files.

With a TAG I mean both freetext and dedicated properties or associations (for example "Date Of Birth = 02052003" where "Date Of Birth" is a predefined very useful tag to have and organise by (Certain routines may be able to automate tasks based on these tags).

I've seen the MS office file properties and quite like the idea of tagging like that (in a way that stays with the file if it is exchanged between users), but the method can't be used on the proprietary binaries.

The application will not always have access to the internet.

Is there a standard for tagging files - or should I just implement my own database and keep track of tags there?

Any ideas welcome.
Posted
Updated 18-May-11 22:33pm
v2

It really depends on what you are planning to do with the files. The Office tags are stored in special properties in the file, and these are displayed out using a shell extension. This allows you to transfer the files between users because the properties are actually part of the files.

If you intend to keep a copy of these files on one machine, and you are using NTFS, you can associate arbitrary tags with the file using something called Alternate Data Streams (ADS), which doesn't store the attributes in the file, but rather keeps a copy elsewhere. Link.[^] Note that this method will require you to get your hands dirty and do a lot of interop[^].

If you want to just store the tags, and the files can be moved between machines, then you should probably consider the use of a database just to store the tags. This is probably going to be the easier method.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 17-May-11 19:46pm    
The advices are valid, my 5, but I think that it is a mistake to try to solve this problem at all.
Please see my answer.
--SA
Dalek Dave 19-May-11 4:38am    
Good Call
Erik Rude 19-May-11 4:38am    
I will go for the own database. Had thought about xml that would accompany the files, but it seems a lousy compromise. Over time I may be able to include tagging like Office by influencing the binary file coder. Not a solution for the text files though.
Erik Rude 7-Jun-11 12:16pm    
Now I just happened to stumble upon these two articles on ADS on a completely separate search :)

Manipulate Alternate Data Streams[^]


Accessing alternative data-streams of files on an NTFS volume
[^]
Bad idea!
No, there are no a standard tagging method. I think, this is because creators of the system would also think it would be a bad idea.

If you explain your ultimate goals (not contaminated with your own architectural ideas you're preoccupied with) you might have a chance to get and advice on some better idea.

[EDIT]
You can always create a data system parallel to the file system itself which hold the tags all files associated with the file names in a "real" file system. You can store it all in a separate single file, not matter in the same file system/volume or not. Some problem would be synchronization with the "real" file systems — files tend to be moved, renamed, deleted or created. This problem can be solved be subscribing to the file system events. For example, with .NET it's done via the class System.IO.FileSystemWatcher.

—SA
 
Share this answer
 
v2
Comments
Erik Rude 19-May-11 4:28am    
I am not sure it is necessarily a bad idea to try to solve the problem or look for standards. Either of the two could lead to easier integration in future versions.

I found this article http://www.codeproject.com/KB/selection/TagCloud.aspx where the author works with TAGs and tagging perhaps choosing 'a standard approach' would enable easy reuse of others code.

Thanks for the advice on sharing the ultimate goal. (btw. I found the tagging of my question quite hard)
Sergey Alexandrovich Kryukov 20-May-11 14:04pm    
You tagged pretty well (just "WPF" + "file system" would suffice), thank you!
(Bad tagging haunt Questions-and-Answers badly.)
Tagging of the file system is harder :-)

You see, when you say "try to solve the problem", I don't know your problem as you apparently refuse to share your ultimate goal. To me, this is not a problem as I reckon tagging of the files is not needed. Apparently, authors of the file system share my view. If you told us why doing so, we would possibly discuss it more productively.

I never say "to... look for standards" is bad. Just the opposite, and the standards say there is not a room for (custom) file object tagging.
--SA
Sergey Alexandrovich Kryukov 20-May-11 14:08pm    
And than you about the reference on Tag Cloud. I'm not well familiar with cloud and not sure this matter is relevant to a file system. Please correct me if you think I'm wrong.
--SA
Erik Rude 25-May-11 9:18am    
In my question I said: Is there a standard for tagging files - or should I just implement my own database and keep track of tags there?

Any ideas welcome.

The answer from you was Bad Idea! - which one? Looking for standard or implement my own database? I agree that I should have shared my end goal from the beginning and then went on to explain my end goal, but probably still not well enough. Any way I will make my app following the advise of separate database for tagging. And the FileSystemWatcher seems interesting.
Sergey Alexandrovich Kryukov 28-May-11 0:56am    
"Bad idea" was about the idea of tagging as I understood it, from the original question. As I understood, you hoped there would be some unused space in the file structure, pretty much like "Object Tag" in Forms controls, to put anything. To best of my knowledge, such room does not exist; and the whole idea would be bad, because who will resolve the conflict if more then one utility compete for using of this room? What is a good idea for some process is not when some system-wide data is involved.

A separate database synchronized with file system using FileSystemWatcher would solve the problem. Thank you for explaining you ultimate goal. It's always good to explain. I must say I'm not excited with the very idea of organizing something about files, but this is not what I called a "bad idea".

Good luck,
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900