c#: how to include filename when sending files to an asmx service -


i have asmx method accepts list of files so:

[webmethod] public void uploadfiles(list<byte[]> files) {  } 

the windows metadata not included in byte array. tried using dictionary<filename, byte[]> classes implement idictionary not serializable. tried using keyvaluepair<string, byte[]>[] imo looks dirty. there other ways include name of file?

as mentioned in comments, can resolved making custom data class.

it's unfortunate dictionaries aren't serializable, it's inherent flaw of xml serialization process. same goes data classes circular references, doesn't work.
wcf, however, has managed fix issues. you're using .asmx (soap), you're stuck unfortunate incompatibility.

i'd make custom class:

[serializable] public class file {     public string filename {get;set;}     public byte[] payload {get;set;} } 

then change web method to:

[webmethod] public void uploadfiles(list<file> files) {     //... } 

simple, effective :)


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -