views:

134

answers:

3

Hi 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

+1  A: 

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.

Tim Schneider
thanks fr reply
Santhosh
+2  A: 

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.

BillW
FileSystemWatcher doesn't supported In .netCF3.5..
Shadow
@Grabit Good catch ! I did review the MSDN docs on FileSystemWatcher before posting, and saw the "disclaimer" (which is pretty ambiguous, imho) down near the bottom where it says "The .NET Framework and .NET Compact Framework do not support all versions of every platform." ... but when I looked at this page : http://msdn.microsoft.com/en-us/library/ms172550.aspx and noticed that various Win Mobile versions, which is a tag the OP used, supported up to FrameWork 3.5, I assumed it would be okay. I should have disclaimered my comments by mentioning I had no experience with Win Mobile or CF.
BillW
+2  A: 

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

Shadow