开发者

Is there anything unique for file and folder in windows c#?

I am working on files n folder using C#....May I know is there any way to get the UID for file-folders....Till now 开发者_开发问答i was using the full path of the file....But my problem in is renaming of files n folder...which will change the UID for file folder.. Plz is ther any way to do the same thanks in advance


First, I think you can get clearer responses if you more clearly define what you mean by "working on files."

No, there's nothing like a "UID" for file or directories. But if you wish to dynamically monitor the state of files and directories, and have events raised notifying you when they are moved/changed/deleted, etc. You can use .NET's FileSystemWatcher class.

Using that technique you could start off, for example, with a Dictionary whose key might be some UID or GUID, or whatever, of the form Dictionary<UID,string>, where string might be the original filename. You could then, as you receive events from the FileSystemWatcher, update a second Dictionary<UID,string> where its string might be the changed file path :

I'm not really proposing you specifically use Dictionaries here, but just using them as possible examples of data structures you could create to keep track of certain files by original name/location and by (possibly) changed name/location ... or if they are deleted, copied, etc.


Hey.. there is a sample provided by microsoft.. it is installed in

"Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\FileChangeNotif"

location of your hard drive..

through filechangenotif smaple you will get the information about file change notification like Renaming file,Deletion, addition...hope this can help you


Sorry, there's nothing you can reliably trace that's retained after a file/folder is moved or renamed. Your only real option is to keep track of the renames or simply tell the user that the file's not there anymore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜