Newbie question Which collection should I use to store such a structure?
Files Archive --------------- File ID: Int Filename: String Path: String You will need to store many file data in the archive, find the path to the FileId field, delete the item through the FileId field.
Since you have several pre-defined pieces, which are related to each value frequency, I To keep the required information for the file, I will start by defining a structure:
Public Structure CustomFileInfo // Choose a name that the system IO {fights with the int file id for public reading; Public readonly string filename; Public readonly string path; // Constructor public customfileInfo (int file ID, string filename, string path) {this.FileId = fileId; This.FileName = fileName; this. Path = path; }} and then I will use a common archive (such as) to keep an example of that structure:
list & lt; FileInfo & gt; MyFiles = new list & lt; FileInfo & gt; (); Alternatively, you can use the FileId key and the FileInfo structure as values. For example: dictionaries & lt; Int, FileInfo & gt; MyFiles = New Dictionary & lt; Int, FileInfo & gt; (); The advantage of a dictionary is that it provides fast lookup time when searching the file for an ID because the one dictionary is internally applied using a hash table. goes.
Edit: Note that if you need to be able to change the different pieces of information describing a file (and I can not imagine that Why would you do this?), You should declare CustomFileInfo as a class instead of struct .
Comments
Post a Comment