AnsweredAssumed Answered

How to create NamedValue in .NET 2003 / .NET 2005

Question asked by kannank on Apr 1, 2006

Thanks for your earlier answers.I am trying to upload an image or text file from local computer to alfresco server.I have referred the following URL from your forum as reference,

I am currently working in .NET 2003 and .NET 2005 with C# - I need a clarification in the above URL post.

1.CMLCreate in .NET also looks different than java - The following is the code snippet with "build sucess" in C# .NET 2005,

ContentFormat formatval = new ContentFormat();
formatval.mimetype        = "text/html";
FileStream fsfile = null;
fsfile = File.Open("D:\\test.txt", FileMode.Open);
byte[] toSend = new byte[fsfile.Length];
fsfile.Read(toSend, 0, System.Convert.ToInt32(fsfile.Length));

NamedValue[] properties = new NamedValue[] { new NamedValue() };
properties[0].name = "test.txt";
properties[0].value = "{}name";

Alfresco.RepositoryWebService.ParentReference parent = new Alfresco.RepositoryWebService.ParentReference(); =;
parent.uuid = reference.uuid;

CMLCreate create = new CMLCreate() = "1";
create.parent = parent; = properties;
create.type = "{}content";

CML cml = new CML();
cml.create = new CMLCreate[1] {(create)};

UpdateResult[] result = repoService.update(cml);
Reference newcontentnode = result[0].destination;

Whether this code is correct or not? What is the correct "properties[0].value" to be used?When I build this code, it says sucessfully builded and when I tried to execute this code this throws error at "repoService.update(cml)" - The error is thrown at invoke method (in reference.cs page),

public UpdateResult[] update(CML statements) {
object[] results = this.Invoke("update", new object[]{statements});
return ((UpdateResult[])(results[0]));

I am not sure what is the problem - Can you please give some clue to overcome this.

Your early message is much appreciated,

Looking for your message,