4

我正在构建自己的"user profile"模块,其中一个选项是用户可以更改他的默认dnn个人资料图像。我在“在后面的代码中”执行此操作时遇到问题。我正在使用c#.

这是我到目前为止所拥有的:

UserInfo myDnnUser = this.UserInfo;
myDnnUser.Profile.InitialiseProfile(PortalId);

myDnnUser.Profile.SetProfileProperty("Photo", "new filename");
myDnnUser.Profile.SetProfileProperty("PhotoURL", "new url");

ProfileController.UpdateUserProfile(myDnnUser);

但它不起作用,当我查看 dnn 使用的“文件”表时,它仍然是相同的(旧)文件名。

有任何想法吗?

4

1 回答 1

8

涉及三个表UserProfileProfilePropertyDefinitionFiles

UserProfile 存储 ProfilePropertyDefinitions 的 PropertyValues。

“照片”PropertyName 的预期 PropertyValue 是对 Files 表的 FileID 引用,而不是文件名。在设置 Photo 之前,您需要获取 FileID:

    var objFiles = new FileController();
    FileInfo objFile = objFiles.GetFile("filepath", PortalID);
    myDnnUser.Profile.Photo = objFile.FileId;
    ProfileController.UpdateUserProfile(myDnnUser);

PhotoURL 是一个只读属性,用于检索 UserProfile 的 Photo 属性的 url。

于 2011-10-14T14:34:04.640 回答