Hi,
I want to create MediaObjectUrl object dynamically to upload image files on my blog.
The images's path has sequence so I want to make the url using for loop.
Here is my source code I have tired like this below but it doesn't work.
Can anybody fix my bad source code
Thank you in advance.
for (int i = 1; i <= 3; i++)
{
MediaObjectUrl[] MO_url= mw.newMediaObject(blogid, username, password, mw.CreateMediaObject(i.ToString()));
}
Post post = new Post();
post.title = "Test Title"";
//내용 작성
post.description = "<img src =" + MO_url[1].url.ToString() +
"<br>" +
"<img src =" +MO_url[2].url.ToString()+">"+
"<br>" +
"<img src =" + MO_url[3].url.ToString() + ">" +
in MetaWebBlogapi.cs
public struct MediaObjectUrl
{
public string url;
}
public struct MediaObject
{
public string name;
public string type;
public byte[] bits;
}
public class MetaWeblogApi : XmlRpcClientProtocol
{
public MetaWeblogApi(String uri)
{
base.Url = uri;
}
[XmlRpcMethod("metaWeblog.newPost")]
public string newPost(string BlogID, string ID, string Password, Post Content, bool Publish)
{
return (string)this.Invoke("newPost", new object[] { BlogID, ID, Password, Content, Publish });
}
[XmlRpcMethod("metaWeblog.newMediaObject")]
public MediaObjectUrl newMediaObject(string BlogID, string ID, string Password, MediaObject MediaObject)
{
return (MediaObjectUrl)this.Invoke("newMediaObject", new object[] { BlogID, ID, Password, MediaObject });
}
public MediaObject CreateMediaObject(string FilePath)
{
if (File.Exists(FilePath) == false) throw new Exception("No file exist");
MediaObject MediaObject = new MediaObject();
MediaObject.name = Path.GetFileName(FilePath);
MediaObject.bits = File.ReadAllBytes(FilePath);
string Extention = Path.GetExtension(FilePath);
MediaObject.type = "application/" + Extention;
RegistryKey Key = Registry.ClassesRoot.OpenSubKey(Extention);
if (Key != null)
{
string Result = (string)Key.GetValue("Content Type");
if (Result != null) MediaObject.type = Result;
}
return MediaObject;
}
}
What I have tried:
..........................................