|
Hey guys, I ve got this question, I tried to look for it online but haven't been lucky!
I've got this:
string[] names = new string[] { "Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan"};
Now I want to fill it from database, so I used a generic list
public List<string> ClassroomList = new List<string>();
then fill it with data from database,
but when I want to assign it to my string I get an error and can't convert it ....
string[] names = new string[10];
foreach (var item in ClassroomList)
{
for (int i = 0; i < names.Length; i++)
{
names[i] = item;
}
}
please help me out.
thanx
|
|
|
|
|
What you are doing there is very odd, filling the array first with the first item, then with the second item, etc.. Eventually you'd have an array with 10 times the same string (the last one in ClassroomList), not a very useful way to spend CPU cycles.
What is your intent? What is the error?
|
|
|
|
|
public List<string> ClassroomList = new List<string>();
...
string[] names=ClassroomList.ToArray();
would probably do it (and it takes care of the array dimension as well, without imposing an artificial limit such as the 10 you had).
|
|
|
|
|
0) Don't use var
1) Don't use foreach in this case
2) Why copy a perfectly good List to an array?
3) If you need an array, why use the List?
|
|
|
|
|
there's more questions than answers here.
|
|
|
|
|
|
Hi
I have an application that uses a 3rd party API that saves a fingerprint image to file,I cannot retrieve the image in any way to a image object in the programming code so I need to save it to disk before i can load it into an Image object to convert the minutiae template between different vendor types. Now due to information law I need to protect that saved fingerprint image, even for the split second it is on the drive before i delete it
So I need to know is there a way I can either
Create a folder, storage space I can save to that only my Assembly can access.
or
Create a virtual drive that encrypts data that gets written into it.
or
Create a folder that requires a password to access it (which I can parse through my program).
Primarily i am using C# to code this application but any C++ console wrapped app that can be of use to me would also help.
Any advice or help will be appreciated.
Hitting my head against the wall on this one
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
Chona1171 wrote: I cannot retrieve the image in any way to a image object in the programming code so I need to save it to disk before i can load it into an Image object to convert the minutiae template between different vendor types.
How does the API return the image?
Chona1171 wrote: So I need to know is there a way I can eitherCreate a folder, storage space I can save to that only my Assembly can access.orCreate a virtual drive that encrypts data that gets written into it.orCreate a folder that requires a password to access it (which I can parse through my program).
SqlCe or SqlExpress, using a blob-field. Or use the encryption-routines that come with .NET.
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: SqlCe or SqlExpress, using a blob-field. Or use the encryption-routines that come with .NET.
It's a 3rd party API, right? If it offered support for those things, surely the OP would have thought of them..
|
|
|
|
|
harold aptroot wrote: surely the OP would have thought of them..
Assumptions, my dear Watson
..I don't expect that the API will save directly to a blob, I'd expect one to get an array of bytes. And yes, those could be securely stored in a blob.
I are Troll
|
|
|
|
|
If you get an array then there is no problem, he could just make the image of that without going through disc, so it can't be that either
btw, I'm just assuming "OP is not an idiot" - I'm sure he will correct me if I'm wrong..
|
|
|
|
|
harold aptroot wrote: he could just make the image of that without going through disc
Yup. Hence the question how the 3d party library supplies the image. If it's in memory, then it can be encrypted, but that doesn't guarantee it not being written to disc.
A SecureString for bitmaps?
I are Troll
|
|
|
|
|
What if he disables the pagefile?
|
|
|
|
|
Guess that'd be safer. It would be a major handicap for a fingerprintingdevice if you couldn't use it on a system that uses virtual memory though. Nah, it's prolly just an array of bytes in memory that need be transformed to a bitmap, with the restriction of not using temporary files.
Must be a good time to get some sleep
I are Troll
|
|
|
|
|
Thats exactly it you do not get an array of bytes. the only image Method available on the entire API is Save
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
the only way it returns an image is a save command with only 1 overload allowing me to save the file to a path.
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
An encrypted volume (think TrueCrypt) would be overkill, but I can't think of any alternatives.
I are Troll
|
|
|
|
|
Something that may help you is the Namespace System.IO.IsolatedStorage, for example IsolatedStorageFile-Class. Sorry, no time to do some tests but read this[^] to get an idea.
|
|
|
|
|
Isolated storage requires me to have the image allready loaded to an object and then to convert it to a byte array.
My main problem is that the 3rd party API only allows me to get the image by storing it in a directory.
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
What exactly does the law require?
|
|
|
|
|
The law requires any and all personal information of an employee that gets saved to disk (id numbers, details ect) needs to be encrypted, or protected In Europe the law currently states that it includes fingerprints, and soon it will be law here in SA.
Now my problem is when the image gets saved to the disk it gets saved as a clear image hence the fact that i need to save it somewhere where no one via the windows shell or dos can get a hold of it even for that split second before it gets pulled back up in memory(Using the Image object i need) and deleted from disk
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
What are the limits of this "save" function? Can it save to a named pipe?
|
|
|
|
|
No only 1 save and its save to directory.
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
What happens if you put in a path to a named pipe anyway? Crash?
|
|
|
|
|
To be honest i haven't tried it but i will give it a go , I read an article about ti and it looks very interesting.
Chona1171
Web Developer (C#), Silverlight
|
|
|
|