public static string CurrentPath = @"F:\"+GetUserId();//PS:定义服务器绝对路径
private string GetUserId(string stUserId)//这里出错:编译器错误信息: CS0161: “_5DDisk.GetUserId(string)”: 并非所有的代码路径都返回值
{
string UserName = Profile.UserName;
MembershipUser mu = Membership.GetUser(UserName);
if (mu == null)
{
Response.Redirect("~/Message.aspx?msn=没有此用户!");
}
else
{
Guid UserId = (Guid)mu.ProviderUserKey;
stUserId = UserId.ToString();
return stUserId;
}
}
我应怎样写才能正确在F:\后加上用户ID?
------解决方案--------------------------------------------------------
并非所有的代码路径都返回值哪里是静态变量的问题?
if (mu == null)
{
Response.Redirect("~/Message.aspx?msn=没有此用户!");
}
这句不能写在函数里面;
改成:
if (mu == null)
{
return "";
}