小编Ami*_*mar的帖子

没有在BIOS设置中启用Hyper-V的选项

我是Windows Phone 8应用程序开发的新手.我安装了SDK 8.0.当我运行我的应用程序时,它显示一个错误告诉我启用Hyper-V.在搜索时,我发现这个MSDN文档 在BIOS中有一个解决方案.但是当进入我的BIOS设置时,则没有可用的选项.

有什么建议?

c# virtualization hyper-v bios windows-phone-7

3
推荐指数
1
解决办法
1万
查看次数

如何将图像文件保存在项目文件夹中?

在我的Windows应用程序中,我有PictureBox一个Button控件.我想从按钮的OnClick事件中加载用户的图像文件,并将该图像文件保存在我项目中的文件夹名称"proImg"中.然后我想在中显示该图像PictureBox.

我写了这段代码,但它不起作用:

OpenFileDialog opFile = new OpenFileDialog();
opFile.Title = "Select a Image";
opFile.Filter = "jpg files (*.jpg)|*.jpg|All files (*.*)|*.*";
if (opFile.ShowDialog() == DialogResult.OK)
{
    try
    {
        string iName = opFile.FileName;
        string filepath = "~/images/" + opFile.FileName;
        File.Copy(iName,Path.Combine("~\\ProImages\\", Path.GetFileName(iName)));
        picProduct.Image = new Bitmap(opFile.OpenFile());
    }
    catch (Exception exp)
    {
        MessageBox.Show("Unable to open file " + exp.Message);
    }
}
else
{
    opFile.Dispose();
}
Run Code Online (Sandbox Code Playgroud)

它无法将图像保存在"proImg"文件夹中.

在此输入图像描述

c# openfiledialog picturebox winforms

2
推荐指数
2
解决办法
4万
查看次数

在mvc中的OnActionExecuting中获取控制器的角色属性

我想在OnActionExecuting方法中读取控制器的过滤器属性.为此我写了这段代码,但这个空数组.

public class BaseController : Controller
    {
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var getActionName = filterContext.ActionDescriptor.ActionName;
            var getControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            var getUserName = User.Identity.Name;
            var getUserRoles = Roles.GetRolesForUser(getUserName);
            foreach (var filter in filterContext.ActionDescriptor.GetCustomAttributes(typeof(Roles), false))
            {
                var desiredValue = filter.ToString();
            }
           //some business logic here 
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是我的控制器

[Authorize(Roles = "Admin")]
    public class AdminController : BaseController
    {
         public ActionResult Index()
        {

            return View();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我想获得执行控制器的允许角色列表.

c# asp.net-mvc actionfilterattribute asp.net-mvc-4

2
推荐指数
1
解决办法
3571
查看次数

等待服务的构造函数中的订阅

在我的服务中,我想等到本地变量baseurl未初始化,然后再发出另一个http请求.

以下是我的服务代码:

@Injectable()
export class CoursesService  {
  baseUrl;
  constructor(private http: Http) {
    if(this.baseUrl != undefined){
      this.getJSON().subscribe(data =>
        this.baseUrl=data, 
        error => console.log(error)
      );
    }
}

public getJSON(): Observable<any> {
  return this.http.get("assets/apiDetails.json")
                  .map((res:any) => res.json());
}

getCourses(){
  return this.http.get(this.baseUrl+"/courses")
    .map((res:any) => res.json());
  }
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的getCourses方法使用baseUrl变量,所以当我调用getCourses方法时,我想等到 baseUrl没有初始化.

我试过使用ngOnInit但它不会在Injectable类型类中调用.

rxjs angular

2
推荐指数
1
解决办法
4354
查看次数

Messagebox功能显示错误

在我的Windows应用程序中,我想当用户尝试datagridview从那时删除一行时应该打开一个消息框,要求用户确认删除该行.

为此,我写了这段代码:

DialogResult res = MessageBox.Show("Are You Sure", MessageBoxButtons.OKCancel);
Run Code Online (Sandbox Code Playgroud)

并检查用户用户响应,但此行显示错误.

这段代码有什么问题?

请帮我.

当我只写这个代码

MessageBox.Show("Are You Sure");
Run Code Online (Sandbox Code Playgroud)

然后它工作正常,但我想再次确认用户,所以我想要他的回复.

c# window winforms

0
推荐指数
1
解决办法
64
查看次数

保持两种形式之间的父子关系

在我的Windows窗体应用程序中,我有两种形式,mainFormrecordForm.在主窗体中有一些文本框和按钮,点击特定按钮我想显示recordForm.

但我希望当第二个表单打开时,用户不能执行任何操作(如填充文本框等),直到第二个表单关闭.我试过这个:

private void tsCustomer_Click(object sender, EventArgs e)
        {
            recordForm customers = new recordForm();
            customers.Show();
        }
Run Code Online (Sandbox Code Playgroud)

tsCustomer是按钮mainForm.我怎样才能做到这一点?

c# dialog winforms

0
推荐指数
1
解决办法
346
查看次数

检查另一个数组中一个数组的元素

我有3个数组,我想检查mainArray中是否存在任何子数组元素 - 然后它应该返回true.

我试过这个,但只有当mainArray包含子数组的所有项时它才返回true.

我的js:

var sub1 = ["0", "10"];
var sub2 = ["18", "3", "13", "4"];
var mainArr = ["0", "1", "5", "8", "9", "10"];
if (containsChk(sub1, mainArr)) {
    alert('yes');
} else {
    alert('no');
}

function containsChk(sub, main) {
    for (var i = 0, len = sub.length; i < len; i++) {
        if ($.inArray(sub[i], main) == -1) return false;
    }
    return true;
}
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

javascript arrays jquery

0
推荐指数
1
解决办法
92
查看次数

c#:没有预定义函数的字符串长度

我正在编写一个代码来查找c#中字符串的总长度.代码如下

class Program
    {
        static void Main(string[] args)
        {
            string str = "Amit Kumar";
            int c = 0;
            for(int i = 0; str[i]!="\n"; i++)
            {

                c++;
            }
            Console.WriteLine(c);
            Console.ReadLine();
        }
    }
Run Code Online (Sandbox Code Playgroud)

但它显示!=运算符不能应用于char或字符串类型的操作数.你能解决我的问题吗?

c#

-2
推荐指数
1
解决办法
738
查看次数